调整BlackBerry上的位图大小

时间:2011-01-31 13:24:05

标签: blackberry

我正在使用BlackBerry Support Forum主题"Resizing bitmap without creating encoded image"调整应用程序中的位图大小。但是使用该线程的代码,我只能从右到左缩小位图,从宽度360缩小到0,如何从左到右调整大小。

1 个答案:

答案 0 :(得分:0)

使用此:

    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();