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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
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?

Highlighted
Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Set image data for empty Bitmap?

Developer
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
Developer
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.

 

 

Developer
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.

Developer
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.