views:

542

answers:

1

I'm looking for a faster way to load JPEG (or PNG?) into a .NET Bitmap on Windows Mobile...

I've just had a go at loading JPEG, PNG and GIF:

for (int i = 0; i < files.Length; i++)
{
    int tries = 10;
    while (--tries > 0)
    {
        int size = (int)new FileInfo(files[i]).Length;
        FileStream fs = new FileStream(files[i], FileMode.Open);
        sw.Reset();
        sw.Start();
        Bitmap b2 = new Bitmap(fs);
        sw.Stop();
        Debug.WriteLine(files[i] + "\n\t" + 
            sw.ElapsedMilliseconds.ToString());
        fs.Close();
    }
}
JPEG (medium)        100ms~
JPEG (medium prog.)  200ms~
PNG  (64 colour)      50ms~
GIF  (32 dith)        50ms~

The managed Bitmap class probably isn't the fastest - but does anyone know for sure?

A: 

There really isn't anything else. You could use something like the Imaging APIs to load it, but 1) I doubt it will be really any faster and 2) you then couldn't use it as a Managed Image or Bitmap, so it would be pretty useless (plus I/m pretty sure that's what the framework is doing anyway).

How big (resolution and color depth) are these images? That's going to be the large factor is how long it takes to load.

ctacke
I thought about using native code instead, but like you said - I'd probably be using the same API and so I'd only shave fractions (if anything) of execution.The images are 320*240 or smaller. Bitmap was fast but it took so much longer to load them off the network that it didn't matter.
Ben
PS: I wanted 16bit, but I reckon I'll have to lower that.
Ben