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: 1,627
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

how to load bitmap faster from sd card?

anyway to speed up the loading of bitmap eg: jpg file from SD card?

I noted the Media app can load the pic really quick.  i'm using the following code.

 

 

                    byte[] data = new byte[available];
                    input.read(data, 0, available);
                    EncodedImage image =  EncodedImage.createEncodedImage(data,0,data.length);

 

 

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

Re: how to load bitmap faster from sd card?

I know of no faster way.

 

I am concerned about your use of available.   Use filesize in preference to <stream>.available(), as available() does not guarantee to give you the entire file and typically gives you 0.

Developer
Posts: 1,627
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: how to load bitmap faster from sd card?

sorry available is

 

int available = (int)fconn.fileSize();

 

so how come the Media app can display the file so fast?

 

 

Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: how to load bitmap faster from sd card?

They use cached images, they're smaller and since they are all kept in one file so they just need one thread and can simply load in the data and convert it to a bunch of Bitmaps.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: how to load bitmap faster from sd card?

IF you ever open the media app right after loading some pictures to it from your pc, you will see it say scanning. This is when it is loading the images to the BB.dat file that resides in most if not all folders with images. There was another thread on here where a user wrote code to parse this file and get the thumbnail images, but I'm not sure what thread it was.

Highlighted
Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: how to load bitmap faster from sd card?

Here's the link you were looking for:

http://supportforums.blackberry.com/t5/Java-Development/Thumbnails-work-around/m-p/343870#M63211

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Posts: 1,627
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: how to load bitmap faster from sd card?

thanks.  I read that thread before. 

 

I dont need thumbnails because i'm actually loading the image.

that is why i was curious why the differences.