BB下如何缩图

1 view
Skip to first unread message

LU WEI

unread,
Feb 16, 2009, 6:41:14 AM2/16/09
to blackberry-dev
其实就是如何使用 EncodedImage.scaleImage32

如果我想让宽度不变,高度变为1/2, 应该怎么弄?


LU WEI

unread,
Feb 16, 2009, 9:56:06 AM2/16/09
to blackberry-dev
解决了:

EncodedImage ei = EncodedImage.createEncodedImage(data,
arrayIndex, data.length - arrayIndex);

/**
* Change this number, <100 makes the image bigger by
* percentage. i.e. 90 makes the image 110% normal
size.
* By increasing, you will reduce the image size,
* e.g. 110 makes the image 90% normal size.
*
*/
int divisor = Fixed32.toFP(100);
int multiplier = Fixed32.toFP(170);

/**
* width
*/
int fixedX = Fixed32.toFP(1);
fixedX = Fixed32.div(fixedX, divisor);
fixedX = Fixed32.mul(fixedX, multiplier);

/*
* height
*/
int fixedY = Fixed32.toFP(1);
/** divide the image scale by 100. */
fixedY = Fixed32.div(fixedY, divisor);
/** multiply the image scale by the multiplier. */
fixedY = Fixed32.mul(fixedY, multiplier);

cameraImage = ei.scaleImage32(fixedX, fixedY).getBitmap
();

Taigoo Zhang

unread,
Feb 18, 2009, 2:42:09 AM2/18/09
to blackberry-dev
多想,多找,问题会解决的
Reply all
Reply to author
Forward
0 new messages