If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
shism2
Posts: 246
Registered: ‎12-13-2010
My Device: Not Specified

Set image data for empty Bitmap?

[ Edited ]

Ok, so my goal is to :

 

1. Read some bytes from a httpconnection where the url is located

2. Use that information to construct an empty bitmap with the width and height

3. Read all the bytes from httpconnection and populate the empty bitmap with that information

 

 

The question I have is that let's say the external image I'm reading from is a png. What function of the Bitmap class can I use to populate the empty bitmap with the full byte array that I read? Will  setRGB565 work in this case? Or is it just not possible?

Please use plain text.
Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Set image data for empty Bitmap?

Please use plain text.
Developer
shism2
Posts: 246
Registered: ‎12-13-2010
My Device: Not Specified

Re: Set image data for empty Bitmap?

Encodedimage doesn't allow to set the image data on an already created object
Please use plain text.
Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Set image data for empty Bitmap?

Hi @

 

I just re-read your message and saw that I understood something else completely...

 

Anyway, can you please give some more details on your requirements?

In particular, why do you need to create an empty bitmap and only after to populate it...

 

E.

 

 

Please use plain text.
Developer
shism2
Posts: 246
Registered: ‎12-13-2010
My Device: Not Specified

Re: Set image data for empty Bitmap?

[ Edited ]

Requirements are:

 

1.Create empty bitmap with dimensions of not completely downloaded image

2. Add bitmap to UI

3. Add data to bitmap

 

Using this technique I can reduce layout interruptions/lag caused by having to scale the image to the correct size. I can then then just call invalidate instead of updateLayout.

Please use plain text.
Developer
shism2
Posts: 246
Registered: ‎12-13-2010
My Device: Not Specified

Re: Set image data for empty Bitmap?

I've attached a class that does the first part. You will need to modify it to store all the read bytes into the bytearrayoutputstream for every function. I only did it for the png file. You must use those bytes and append to the beginning of the rest of the stream you read in for the stream to be read correctly.

Please use plain text.