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: 135
Registered: ‎08-27-2008
My Device: Not Specified

How to display Large size image

Hello EveryBody,

 

I am developing the application in which I am downloading large images from server and storing it in

particular location on device

 

I have to display that downloaded images on screen with Horizontally and vertically centered position

 

if the image size is small then it should fit at center of the screen

 

& if the image large then it should resize.

 

In short in media browser if we open any image then it fits automatically.

 

same thing,  I have to do using my application.

 

I have tried the code given in the forum

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=1640

 

but this does not work for large images i.e. image size greater that 800kb.

 

How to do that ? any ideas

 

Thanks in advance.

 

 

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: How to display Large size image

Implement your own control to show large images, for example your own BitmapField that interacts with keys to show image by parts.

 

Download image to the memory and show one part of it.

 

When a scroll key pressed or trackwheel action performed - repaint your control to show different part of your image.

Developer
Posts: 19,628
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to display Large size image

See this post for scrolling code:

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=595&query.id=3762...

 

What happens with the large images - you tell us it doesn't work but not what goes wrong.

Developer
Posts: 135
Registered: ‎08-27-2008
My Device: Not Specified

Re: How to display Large size image

when I tried to display the images having size greater than 800Kb it gives outOfMemoryException
Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: How to display Large size image

Is there a way to split big image files to parts and load/show them step by step ?
Developer
Posts: 19,628
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to display Large size image

Can you confirm my understanding that you want to be able to show the complete image, scaled down if too large, on the Blackberry screen? 

 

What resolution are these large images?  Have you figured out how much storage it will take to convert the whole image to ARGB?  For example, if these images are 800*600, then I think the ARGB form would require 800*600*4 bytes, i.e. approximately 2MB.  If your images are larger than this, I'm not surprised you are running out of memory. 

 

If this is the case, then I suspect that you can rework the algorithm to do a bit at a time, then use the x,y, width and height in the getARGB routine to extract subsets of the data.  Doing it bit at a time means you don't have the entire image in memory at once.

 

Just a thought.

 

Developer
Posts: 135
Registered: ‎08-27-2008
My Device: Not Specified

Re: How to display Large size image

Yes, Peter I want to show the complete image, scaled down if too large, on the Blackberry screen.

 

But in native file browser if I tried to open that image then it shows correctly.

 

what technique is used in native file browser ?

 

 

 

 

Developer
Posts: 146
Registered: ‎11-05-2008
My Device: Not Specified

Re: How to display Large size image

Hi,

If u want to scroll large image that is greater than scrwidth and scheight of BB,then use navigationMovement method,from here u can get dx,dy value in both direction and after calculating,in which manager u have added this image just use setHorizontalScroll or setVerticalScroll with the value,which is how much u want to scroll.

 

Developer
Posts: 19,628
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to display Large size image

How does the native browser do it?  Don't know sorry, don't work for Rim.......

 

But I reckon if they tried to load the entire image and convert it using ARGB format, they too would run out of memory.  I'll bet they have some very clever processing that scales as it as it is converting the png/jpg/whatever file for display anyway.  But I suspect you do not want to know the intricacies of a compressed picture files, which is why I suggested doing it bit at a time.  I think that approach will work.