开发者

Resizing bitmaps on BlackBerry

I a开发者_运维百科m working with resizing bitmaps in an application by using the BlackBerry Support Forum thread "Resizing bitmap without creating encoded image". But with the code from that thread, I can reduce the bitmap right-to-left only, from width 360 to 0, how can I resize it left-to-right.


Use this:

    int oolddWidth;
int oolddHeight;
int ddispplayWidth;
int ddispplayHeight;
EncodedImage eih1 = EncodedImage.getEncodedImageResource("add2.png");
oolddWidth = eih1.getWidth();
oolddHeight = eih1.getHeight();
ddispplayWidth = Display.getWidth()-40;
ddispplayHeight = 80;
    int nnumeerator = net.rim.device.api.math.Fixed32.toFP(oolddWidth);
    int ddenoominator = net.rim.device.api.math.Fixed32.toFP(ddispplayWidth);
    int wwidtthScale = net.rim.device.api.math.Fixed32.div(nnumeerator, ddenoominator);
    nnumeerator = net.rim.device.api.math.Fixed32.toFP(oolddHeight);
    ddenoominator = net.rim.device.api.math.Fixed32.toFP(ddispplayHeight);
    int hheighhtScale = net.rim.device.api.math.Fixed32.div(nnumeerator, ddenoominator);
    EncodedImage newEih1 = eih1.scaleImage32(wwidtthScale, hheighhtScale); 
    final Bitmap header1 = newEih1.getBitmap();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜