07-10-2007, 05:39 AM
|
#2 (permalink)
|
| CrackBerry Addict
Join Date: Jun 2005 Location: Manchester, UK Model: BOLD Carrier: t-mobile
Posts: 714
Post Thanks: 0 Thanked 0 Times in 0 Posts
| mdwheaton over on the official bberry dev forum posted this code that works well, i've used it before:
EncodedImage bitmap = null;
String path = "/classpath/to/image.png";
InputStream in = ThisClass.class.getResourceAsStream(path);
byte[] data = new byte[in.available()];
in.read(data);
bitmap = EncodedImage.createEncodedImage(data, 0, data.length);
int divisor = Fixed32.toFP(100);
/**
* 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 multiplier = Fixed32.toFP(110);
int fixedX = Fixed32.toFP(1);
/** First, divide the image scale by 100. */
fixedX = Fixed32.div(fixedX,divisor);
/** Now, multiply the image scale by the multiplier. */
fixedX = Fixed32.mul(fixedX,multiplier);
int fixedY = Fixed32.toFP(1);
fixedY = Fixed32.div(fixedY,divisor);
fixedY = Fixed32.mul(fixedY,multiplier);
bitmap = bitmap.scaleImage32(fixedX,fixedY);
in.close();
BitmapField bmp = new BitmapField();
bmp.setImage(bitmap);
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
|
| Offline
| |