Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 745
Registered: ‎01-04-2009
My Device: 8300, 8800, 8700f, 9000

Re: is it possible to dump a bitmap to *.bmp file?

i tried four combinations:

1. Bitmap _bitmap= new Bitmap(Display.getWidth(), Display.getHeight()); Display.screenshot(_bitmap); JPEGEncodedImage _jpg = JPEGEncodedImage.encode(_bitmap, 50); EncodedImage _enImage = EncodedImage.createEncodedImage(_jpg.getData(), 0, -1, "image/bmp"); 2. byte[] _a = getBytesFromBitmap(_bitmap); EncodedImage _enImage = EncodedImage.createEncodedImage(_a.getData(), 0, -1, "image/bmp"); 3. byte[] _a = getBytesFromBitmap(_bitmap); BMPEncodedImage.createEncodedImage(_a, 0, -1, "image/bmp"); 4. BMPEncodedImage.createEncodedImage(_jpg.getData(), 0, -1, "image/bmp");

 

 

all gave me argument exception..

Developer
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: is it possible to dump a bitmap to *.bmp file?

If the length is -1, then it is an illegal argument right? 

--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
Developer
Posts: 745
Registered: ‎01-04-2009
My Device: 8300, 8800, 8700f, 9000

Re: is it possible to dump a bitmap to *.bmp file?

length - The length in bytes of the encoded image data, or -1 to indicate the entire array should be used.

 

so this is not the problem

Developer
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: is it possible to dump a bitmap to *.bmp file?

Did you try this?

 

getData( ).length

 

as bytes length!

--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
Developer
Posts: 745
Registered: ‎01-04-2009
My Device: 8300, 8800, 8700f, 9000

Re: is it possible to dump a bitmap to *.bmp file?

yes, i've tried. and as i mentioned-it's not the problem...
Developer
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: is it possible to dump a bitmap to *.bmp file?

Oh ok ok.. The document says that if the mime type is invalid, the IllegalArgumentException is thrown..
--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
Developer
Posts: 745
Registered: ‎01-04-2009
My Device: 8300, 8800, 8700f, 9000

Re: is it possible to dump a bitmap to *.bmp file?

yes, ok. but why it is thrown when i use "image/bmp" what is in the api?

Highlighted
BlackBerry Development Advisor
Posts: 15,727
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: is it possible to dump a bitmap to *.bmp file?

Use the encode method of PNGEncodedImage.  This accepts a Bitmap and can be used with the Bitmap returned from the Display.screenshot method.  You can then call getData on the PNGEncodedImage and save the byte array that is returned as a .png file.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 745
Registered: ‎01-04-2009
My Device: 8300, 8800, 8700f, 9000

Re: is it possible to dump a bitmap to *.bmp file?

i was asking about how can i dump a bitmap to *.bmp file, not to png.
Developer
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: is it possible to dump a bitmap to *.bmp file?

I'm sorry, but I see no usage of placing it as a bitmap when there are lot of standard encodings that are supported in blackberry..

 

Cheers.. 

--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group