Reputation: 28989
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).
Upvotes: 1
Views: 3191
Reputation: 36
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+?
Upvotes: 2
Reputation: 391276
By itself, Image.FromFile does not support a lot of image types, but more can be installed.
So, did you install something into Vista that made this work? Like a Nikon Codec pack or something that would add that support?
And that error message means one of two:
I see from the comments that there is some discussion here. I do not know whether Microsoft explicitly pulled the format by themselves, or was forced to do so, but I can confirm that GDI+ does not support NEF on my Windows 7 installation, so regardless of whether XP or Vista supported it, and regardless of the reason for why it is no longer support, Windows 7 does not support NEF-loading in GDI+ out of the box.
So you need to install something.
Upvotes: 0
Reputation: 8129
Did you installed the Nikon Raw Codec? Windows itself (and .NET Framework) does not know to handle Nikons Raw format.
Upvotes: 0