Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top