07-18-2009 02:57 PM
I've been have trouble scaling down a large image (1600x1200) taken
w/ BB camera to fit on the Pearl. I use EncodedImage api to scale it
and pass it to BitmapField. But this cause a system restart. When I
use BitmapField with the image w/O rescaling, I will get an out of memory
exception and my app will not run again. BitmapField will work w/ only
Solved! Go to Solution.
07-18-2009 08:04 PM - edited 07-18-2009 08:04 PM
I had an issue with this, and it seems that on certain devices an arithmatic error will cause the device to reboot. It is probably due to an incorrect size argument on the Bitmap you generate. The getWidth() and getHeight() values will return a Fixed32 value with whatever height and width the scaling of the image produces (even if it is wrong). I resolved the issue by wrapping all the numbers in a Fixed32 object and using the Fixed32.div() method.
Bitmap b = EncodedImage.getEncodedResource("myImage.png").sca
Fixed32.div( Fixed32.toFP(1200), Fixed32.toFP(h_scale) ) );
07-20-2009 09:49 PM
Thanks for help. I am playing with EncodedImage and Bitmap classes and BitmapField.
The scaling works in that I do get the correct width and height for my device
but when I pass an EncodedImage object to Bitmap object, it doesn't keep
the scaled image. Bitmap object has its own scaling parameter that's doesn't
bare good documentation. I don't think going from EncodedImage --> Bitmap -->BitmapField
isn't a good path. I doing looking into paint the scale image manually by override the paint field method.