Loading Bitmaps Efficiently

N

Nathan

The bottleneck for a CF 2.0 application is constructing a Bitmap object
from a MemoryStream formed from a buffer of bytes.

It is about 40 milliseconds to load a jpeg from about 17k bytes. More
than the time it takes to render to another Bitmap.

Can this be done more efficiently?

CF 1.0, OpenNetCf had GraphicsEx and BitmapEx. It required writing the
bits to a temp file, which made it a wash in the old situation, but it
may have changed.

CF 2.0 and OpenNetCf 2 has completely different classes

What is the best way to go about this? If optimization is not possible
in this way, I could pursue other options, like rendering on a separate
thread, etc.

Nathan
 
G

Greg Young [MVP]

40 ms seems to be a small performance hit (if you are only paying it once)
are you caching the images so you are not opening them from a memorystream
every time you go to display them? (lets say you had 10 images = 400 ms at
startup to cache all).

Cheers,

Greg
 
N

Nathan

The idea That would help for 10 or so images out of the hundreds.

But if you are displaying 12-35, and perhaps a completely different set
of them within a few seconds, and you have hundreds of them stored in a
database to choose from.

Am I hearing, then, that it is unlikely to load a 17k jpg image from a
memory stream in less than 40 milliseconds?
 
G

Greg Young [MVP]

A conversion from JPEG is a fairly processor intensive operation ... I would
imagine it to be reasonably performant but ..

Another alternative might be to store your images in a different format
(space for speed). Storing them in a non-compressed format would msot likely
make them significantly faster (but the larger data sizes may make them
slower to open). I would definately try benchmarking it.

Beyond that an intelligent cache would probably go a long way.

Cheers,

Greg
 
N

Nathan

Greg Young said:
A conversion from JPEG is a fairly processor intensive operation ... I
would imagine it to be reasonably performant but ..

Another alternative might be to store your images in a different format
(space for speed). Storing them in a non-compressed format would msot
likely make them significantly faster (but the larger data sizes may make
them slower to open). I would definately try benchmarking it.

Beyond that an intelligent cache would probably go a long way.

May very well be the best I can do. Bitmap and BitmapEx both use
aygshell.dll behind the scenes, I believe. Optimiziations may only make the
rendering part faster.

An adaptive cache could make some common cases faster and leave the worst
case about where it is now.

Nathan
 
H

Harry Simpson

Can the images be stored in the database as pngs? This is lossless yet I
guess still compressed but the file size is really small. I don't think
I've ever tried pngs myself but use jpegs also. With a table of say 25000
people, it'd be pretty prohibitive to try to store that many pics in a
database and RDA pull them down to a local table correct?? I mean I'm
guessing it would and never have tried this....

Back to Ilya's benchmarking, is there any PPC benchmarking test available
online that anyone knows about?

Thanks
Harry
 
N

Nathan

Harry Simpson said:
Can the images be stored in the database as pngs? This is lossless yet I
guess still compressed but the file size is really small. I don't think
I've ever tried pngs myself but use jpegs also. With a table of say 25000
people, it'd be pretty prohibitive to try to store that many pics in a
database and RDA pull them down to a local table correct?? I mean I'm
guessing it would and never have tried this....

Png coudl be interesting. Do you know of code that converts jpg to png on a
Pocket PC?

Nathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top