2012-08-25 52 views

回答

1

按照下列步骤操作:在一面BitmapRotate

从这个链接下载的ZIP 文件

提取并取ImageManipulator.java从添加到您的项目;

,并使用此代码从这个链接:RotatingBitmap on Blackberry

,我认为这可以帮助你;

采取以下BitmapRotate.zip代码为旋转图像从这个链接:

Bitmap rotation in blackberry

+0

我使用此代码,但删除透明度,请给我另一个例子 –

+0

检查更新之一;取邮政编码并运行;然后让我知道。 – alishaik786

+0

请给我链接更新zip文件 –

1

有一个J2ME Army Knife library,检查它。

它也包含旋转功能。

+0

您还可以检查[此链接](HTTP://supportforums.blackberry。 com/t5/Java-Development/how-to-rotate-Image-or-Graphic/mp/232750/highlight/true#M36233)如果有麻烦移植一些J2ME军刀代码可用于RIM的类库(例如'Bitmap') – Nate

1

这是黑莓知识库文章的一部分.. 传递你的位图&角度到这个函数得到旋转位图。

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; 
} 
+0

它不起作用 –

+0

你面临什么问题......? –

+0

旋转功能如何发送 valuse位图rotate = rotateSquareImage(oldBitmapSquared,);以及如何使用rotateSquareImage函数我修改公共静态位图旋转(位图oldImage,int ang)并传递位图rotate = rotateSquareImage(oldBitmapSquared,ang);但PNG位图不旋转 –