The following piece of source does run nicely with Windows up until vista.
With Windows 7 (and the new .net 3.5) it always produces an out of memory exception, when I try to load a raw image file from my Nikon D90.
Some might say “loading nef’s is not supported”, but it did run nicely up until vista, only Windows 7 broke it, so I’d disagree.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace QuickImageLoader
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
DialogResult res = openFileDialog1.ShowDialog();
if (res == DialogResult.OK)
{
pictureBox1.Image = Image.FromFile(openFileDialog1.FileName); // crash happens
pictureBox1.Refresh();
}
}
}
}
Download a sample nef file to reproduce error.
Is this a bug in Windows 7? In .net 3.5? Or is it something that should have never worked with XP/Vista?
[Update] Since a few people neither know nor read my introduction above: loading the nef like this does work on XP/Vista without installing the Nikon Raw Codec. And installing the codec does not solve the problem (folks, it got nothing to do with the codec sigh).
I can confirm this behavior for JPEG photos coming from a Nikon Coolpix P5000.
It seems that there is some problem with the internal structure of the file, which confuses the GDI+ jpeg loader.I used an external image viewer just to recode the images as jpg and then everything went to normal. I cannot confirm if this behavior is found only on Win7
So did anybody found the cause of this? Or perhaps it’s a bug in GDI+?