Hy。我要水平翻轉圖像,我用這個代碼:如何翻轉EncodedImage黑莓
public static EncodedImage flip (Bitmap png)
{
int width = png.getWidth();
int height = png.getHeight();
Bitmap temp = new Bitmap(width,height);
int[] argb = new int[ width * height ];
int[] invertArgb = new int[ width * height ];
png.getARGB(argb, 0, width, 0, 0, width, height);
for (int i = height - 1; i >= 0; --i) {
for (int j = width - 1; j >= 0; --j) {
invertArgb[ (width - j - 1) + (width * i) ] = argb[ j + (width * i) ];
}
}
temp.setARGB(invertArgb, 0, width, 0, 0, width, height);
PNGEncoder encoder = new PNGEncoder(temp, true);
byte[] imageBytes = null;
try {
imageBytes = encoder.encode(true);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
EncodedImage fullImage = EncodedImage.createEncodedImage(imageBytes, 0, imageBytes.length);
return fullImage;
}
Buut ..沒有人有一個IDEEA如何直接EncodedImage
翻轉無需轉換,因爲它採取長期
附:一點點PNGEncoder.java在這裏:http://www.mobiyana.com/code/blackberry/PNGEncoder.java
是的,但我做了一個遊戲,首先我需要加載翻轉的圖片並在遊戲中畫出 – AndreiCatalin 2011-05-10 10:51:44
不明白!你能更清楚嗎? – 2011-05-10 11:45:51