2012-08-25 80 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位圖不旋轉 –