BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   Getting Image from BitmapField (http://www.blackberryforums.com/developer-forum/77366-getting-image-bitmapfield.html)

Cycom 05-21-2007 02:07 AM

Getting Image from BitmapField
 
Hi.

I'm wondering is any way to get an image in any form that was modified in BitmapField?

May be I've got not very good application architecture, that I'm need such functionality? But I see getText method in TextFiled, and I'm wondering why I can't get image?

I want to do next thing:
1. I have a CLDC application with Bitmap field that shows a bitmap image.
2. I have to draw some additional graphics on that bitmap and I do so.
3. I have to save modified image to file system or send it.
An I have problems with getting this image back.

Can someone give me an advice how it could be done?

Thank you,
Cycom

jfisher 05-21-2007 02:59 AM

to set your edited bitmap to the bitmapField you must surely draw it to a bitmap first? ie. you can't draw directly to the bitmapfield - you must be drawing to a bitmap somewhere so why not just cache or save this?

Cycom 05-21-2007 04:13 AM

jfisher, thank you for reply but it is not clear for me what I have to do.

I'm using JDE 4.2.1.40. In BitmapField class I see method paint(Graphics g);
So I can override this method in my class and paint directly at BitmapFiled and I do so.

I do not see a possibility to paint at Bitmap itself.

Could you, please help me?

Thank you,
Cycom

jfisher 05-21-2007 04:28 AM

aah i see. instead of drawing straight to the bitmapfield draw to a bitmap and then populate the bitmap field for display:

Bitmap myBitmap = new Bitmap(240, 100);
BitmapField myBitmapField = new BitmapField(myBitmap, BitmapField.FOCUSABLE);
Graphics myGraphics = new Graphics(myBitmap);

myGraphics.setColor(0xFF0000);
myGraphics.fillRect(10, 20, 10, 10);
myGraphics.drawText("myText", 20, 5);

myBitmapField.setBitmap(myBitmap);

Cycom 05-21-2007 09:58 AM

Thank you, now it is works much better.

One more quersion.
Is any way to convert that Bitmap to EncodedImage to save or scale at screen?

Thank you,
Cycom


All times are GMT -5. The time now is 07:49 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.