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: 202
Registered: ‎04-19-2011
My Device: Blackberry Bold 9780

Multithreading file image loader

Hi, developers..

I want to create a custom file picker component. So, All OS version that didn't support File Picker can still choose picture from their device...

I've already created the custom file picker, but it's still takes too long time for reading a lot of images from device..

Is there any multithreading ways to read n make thumbnail for showing all of images from Blackberry?

Thanx for your help..

Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: Multithreading file image loader

One thing I would definitely suggest - have two different threads for reading images from the file system (#1) and for creating the thumbnails (#2). #1 is I/O intensive while #2 is CPU-intensive - this makes them an ideal pair for this job. Make sure your I/O thread has higher priority.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
Posts: 202
Registered: ‎04-19-2011
My Device: Blackberry Bold 9780

Re: Multithreading file image loader

Thanx for the idea...

Is there any source code for learning this methods?

two thread that you mention, is it start in the same time? or the I/O thread must be start first, after get the first image, then the seconde thread is starting for resize the bitmap?

Developer
Posts: 202
Registered: ‎04-19-2011
My Device: Blackberry Bold 9780

Re: Multithreading file image loader

thanx peter for the links..

i've already read these links...

For thumbnails work around, is it just suitable for PNG format?

Or it can be used for JPEG format also?

Can you explain to me how it works?

Many thanx for all...

Developer
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Multithreading file image loader

It's only PNG, J2ME's native image format is PNG so that's what is used. Just in addition to Peter's post, I had a post about the "new" thumbnail format used in 5.0 and higher:

http://supportforums.blackberry.com/t5/Java-Development/BBThumbs-dat/m-p/552778/message-uid/552778/h...

 

The function doesn't brute-force the seraching of images so it should be fast.

---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: 202
Registered: ‎04-19-2011
My Device: Blackberry Bold 9780

Re: Multithreading file image loader

So, what i mean is, this generate thumbnail just for loading PNG file? or create a file with format PNG?

Still confused about the source code actually...

Can you give me hint for how to use it?

Really apreciated it...

Thanx for the answer, and pardon me if i don't understand

Developer
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Multithreading file image loader

Well, it gets you the PNG image data.

 

For devices <=4.7:

  1. Get folder path
  2. Open stream BBThumbs.dat in that folder
  3. Read all data from stream with something like IOUtilities
  4. Call readThumbs with data from #3 and name of image you are looking for.
  5. If image data exists in thumbnails then you'll get an array of bytes back (for later)
  6. Cleanup

For devices >= 5.0:

  1. The different thumbnail sizes are stored in "system/appdata/rim/media", open the desired size "dat" file
  2. Get the file size.
  3. Create a new TagGroup("dat stream", "dat size")
  4. Go through each Tag in the TagGroup's "Tags" field until the desired picture is found (Path, Name fields in Tag)
  5. Get the image data from the Tag's Image field.
  6. Cleanup

Now take the data from one of the 2 operations and create an EncodedImage with it. The rest is up to you.

---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: 202
Registered: ‎04-19-2011
My Device: Blackberry Bold 9780

Re: Multithreading file image loader

Hm.. but the problem is i need to read from multiple format image (JPG, PNG, etc)

Is this method usable for my problem?

Developer
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Multithreading file image loader

At first I wasn't sure I understood your question but I think I get it now.

 

If you are reading the images themselves then just use an EncodedImage, it takes all supported image formats.

 

But BlackBerry has specific files that contain the thumbnails of images. The previously mentioned posts are mostly on how to use these. That way you don't need to scale the image and they are already at thumbnail size.

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