Jpeg library - display large images on the device

agraham

Expert
Licensed User
Longtime User
Cameras on devices are getting higher in resolution but displaying those images in the Compact Framework is not possible owing to memory limitations on the device. Native code applications that can display such images do so by only decoding partial images using very low level techniques. I have licensed the source code of a native code library that does such manipulation and agreed terms that Basic4ppc users may, without further licensing, use the resulting library and it's .NET wrapper for personal use. Full terms of the license are in the help.

This first iteration of the library can display and save reduced size versions of complete large images without running into memory problems. I will add decoding of partial areas of large images once I am a bit more familiar with the functionality available.

The library requires .NET 2.0. Help and a very small demo are included but you will need your own large image to try it. I am afraid that source code for merging the .NET wrapper part of the library is not available.

EDIT :- Version 1.1 posted. See post #6 for details.
 

Attachments

  • Jpeg1.1.zip
    66.9 KB · Views: 261
Last edited:

HARRY

Active Member
Licensed User
Longtime User
Hi Agraham,

Fantastic. I have done a quick test on my device and it works. I will now implement it in the program where large images gave problems. I will inform you.

Harry
 

HARRY

Active Member
Licensed User
Longtime User
Hi Agraham,

Also in my program that new library works very well. Still I have two questions, just for my understanding:

1) The Load method does not reduce the bitmap, does it? I wonder whether the Load method really will prevent OutOfMemory. In my understanding the size of the JPEG file is not the reason for this message , but the size of the decoded bitmap. The code will try to allocate a block of memory with a size of roughly image width * image height* 3 or 4 bytes. Am I right?

2) The LoadThumbnail method does not read the thumbnail in the JPEG file, but makes a kind of thumbnail. At least if I specify a small width and height. Am I right?

The quality of the image is such good that it can hardly be a blown up version of the thumbnail in the JPEG file, which is not always present anyhow, I believe.

Harry
 

agraham

Expert
Licensed User
Longtime User
1) The Load method does not reduce the bitmap, does it?
No, it just loads it like you say so it will cause problems on large images.

2) The LoadThumbnail method does not read the thumbnail in the JPEG file, but makes a kind of thumbnail.
Yes, I tried to explain in the help - I'll try to make it clearer for the next release. The file is read in one scan line of the image at a time. The scan line is compressed to the width you specify, for high quality it is interpolated, for low quality bytes are discarded. For high quality as many scan lines as are needed to form one scan line of the thumbnail are interpolated vertically, for low quality scanlines that are not needed are discarded.
 

agraham

Expert
Licensed User
Longtime User
Version 1.1 now posted.

Added GetSize to return the width and height of an image without having to load it and possibly run into memory problems.

Added LoadArea which will load a part of a large image at full size.

Added LoadAreaThumbnail which will load part of a large image resized to fit into a specifed area.

Hopefully, together with BitmapEx from ImageLibEx, this should be all you need to manage and display large images.
 
Top