views:

894

answers:

1

I'm using the Blackberry JDE (9000 simulator), and am wondering if I can display an image from the web. Currently, I'm seeing tutorials that use Bitmap.getBitmapResource to display images that are local to the blackberry application, but looking at the API, I'm not seeing any support for giving a web URL. Are there other Blackberry image classes I can check out? Or is this feature just not supported?

-Jenny

+3  A: 

You can download image using HTTPConnection and InputStream, create EncodedImage from stream and then display it.

See coderholic - Blackberry WebBitmapField

BTW, you can use IOUtilities.streamToBytes() method to read bytes from InputStream directly!

Max Gontar
But, given that currenly all the ways to display something on a screen involve a "field" class...and there is only a bitmap field...does that mean to display the EncodedImage I'd have to write my own field? Or is there an alternative way to display an image? If so, what is it?
Jenny
If you read linked article, that is ok to setImage(EncodedImage) to BitmapField. But if you want, you can do graphics.drawImage() on paint() event in any class which extands Field, ex. in MainScreen, or HorizontalFieldManager.
Max Gontar
But its a new functionality to stream data for image from web, so I would suggest you to implement an extention to BitmapField, so you'll be able to use it many times.
Max Gontar
That tutorial seemed to do a lot of things. I did, however, get an image to display by looking at it. It seems weird to want to extend BitmapField, to me, when BitmapField already handles EncodedImages, and they don't seem that hard to generate. Thanks for the tips!
Jenny
) Your'e welcome!
Max Gontar