1
我想縮小包含透明度的位圖。不幸的是,我嘗試過的所有三種方法在白色應該是完全透明的。我想保持透明度。在BlackBerry上縮放位圖並保留Alpha alpha
我縮放位圖總是平方,所以我的功能假設:不是圖形
private static Bitmap scale1(int edge, final Bitmap res) {
int factor =
edge == 0 ? Fixed32.ONE : Fixed32.div(res.getHeight(), edge);
Bitmap scaled = PNGEncodedImage.encode(res).
scaleImage32(factor, factor).getBitmap();
return scaled;
}
private static Bitmap scale2(int edge, final Bitmap res) {
Bitmap val = new Bitmap(edge,edge);
val.createAlpha(Bitmap.ALPHA_BITDEPTH_8BPP);
res.scaleInto(val, Bitmap.FILTER_BILINEAR);
return val;
}
private static Bitmap scale3(int edge, final Bitmap res) {
Bitmap val = new Bitmap(edge,edge);
val.createAlpha(Bitmap.ALPHA_BITDEPTH_8BPP);
Graphics g = new Graphics(val);
int[] pathX = new int[] {0, 0+edge, 0+edge, 0};
int[] pathY = new int[] {0, 0, 0+edge, 0+edge};
byte[] pathPointTypes = new byte[] {
Graphics.CURVEDPATH_END_POINT,Graphics.CURVEDPATH_END_POINT,
Graphics.CURVEDPATH_END_POINT,Graphics.CURVEDPATH_END_POINT};
int factor =
edge == 0 ? Fixed32.ONE : Fixed32.div(res.getHeight(), edge);
g.drawTexturedPath(pathX, pathY, pathPointTypes, null,
0, 0, factor, Fixed32.toFP(0), Fixed32.toFP(0), factor, res);
return val;
}
你能看看這個問題嗎? http://stackoverflow.com/questions/5298718/resize-bitmap-on-blackberry-while-keeping-alpha-data我有一種感覺,你可能能夠回答它。 – 2011-03-14 12:47:58
你能發表一個你如何使用drawARGB的例子嗎? TNX – 2012-03-22 11:30:26