私はBlackberryに少し慣れていません。ユーザーからの入力に応じてある程度回転させる必要のある画像があります。検索してみましたが、何も見つからないようです。誰かが私を正しい方向に向けることができますか?
質問する
392 次
3 に答える
1
次の手順を実行します:
このリンクからzipファイルをダウンロードします:下側のBitmapRotate。
プロジェクトに追加したImageManipulator.javaを抽出して取得します。
そして、このリンクからこのコードを使用してください:BlackberryのRotatingBitmap
これはあなたに役立つと思います。
また
以下のBitmapRotate.zipコードを使用して、このリンクから画像を回転させます。
于 2012-08-27T06:22:05.280 に答える
1
J2MEアーミーナイフライブラリがあります。確認してください。
回転機能も含まれています。
于 2012-08-25T11:06:12.427 に答える
1
これはBlackberryのKB記事の一部です..ビットマップとAngleをこの関数に渡して、回転したビットマップを取得します。
public static Bitmap rotate(Bitmap oldImage) throws Exception
{
int w = oldImage.getWidth();
int h = oldImage.getHeight();
int d = Math.max(w, h);
int amountPxAdded = 0;
if (w > h) {
amountPxAdded = w - h;
}
Bitmap oldBitmapSquared = new Bitmap(d, d);
int[] data = new int[w * h];
oldImage.getARGB(data, 0, w, 0, 0, w, h);
oldBitmapSquared.setARGB(data, 0, w, 0, 0, w, h);
Bitmap finalRes = new Bitmap(h, w);
int fW = finalRes.getWidth();
int fH = finalRes.getHeight();
oldImage = null;
Bitmap rotated = rotateSquareImage(oldBitmapSquared, <Angle>);
oldBitmapSquared = null;
data = new int[fW * fH];
rotated.getARGB(data, 0, fW, amountPxAdded, 0, fW, fH);
rotated = null;
finalRes.setARGB(data, 0, fW, 0, 0, fW, fH);
return finalRes;
}
private static Bitmap rotateSquareImage(Bitmap oldB, int angle) throws Exception {
int w = oldB.getWidth();
int h = oldB.getHeight();
Bitmap newB = new Bitmap(w, h);
int[] oldD = new int[w * h];
int[] newD = new int[w * h];
oldB.getARGB(oldD, 0, w, 0, 0, w, h);
int[][] old2d = new int[h][w];
int[] js;
int old2dLen = old2d.length;
int jsLen;
for (int i = 0; i < old2dLen; i++) {
js = old2d[i];
jsLen = js.length;
for (int j = 0; j < jsLen; j++) {
js[j] = oldD[i * w + j];
}
}
int[][] rotated = new int[h][w];
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
rotated[i][j] = old2d[h - j - 1][i];
}
}
old2d = null;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
newD[i * w + j] = rotated[i][j];
}
}
rotated = null;
newB.setARGB(newD, 0, w, 0, 0, w, h);
return newB;
}
于 2012-08-27T04:43:11.007 に答える