The program breaks at the Image.LockBits(new rectangle(x, y, width, height), ImageLockMode.ReadWrite, Image.PixelForma) method with the exception I mentioned in the title. I checked the image format and everything. I'm stumped.
private unsafe void frmArtAnalyzer_Load(object sender, EventArgs e)
{
// Load Default Canvas
imageX = gbImageView.Location.X + gbImageView.Size.Width + 16;
imageY = 16;
Image = new Bitmap(640, 480, PixelFormat.Format24bppRgb);
ImageData = Image.LockBits(new Rectangle(imageX, imageY, 640, 480), ImageLockMode.ReadWrite, Image.PixelFormat);
{
// Fill canvas
byte* row;
int scan0 = (int)ImageData.Scan0;
for (int y = 0; y < ImageData.Height; y++)
{
row = (byte*)scan0 + ImageData.Stride * y;
for (int x = 0; x < 640; x++ )
{
row[x * 24] = 255;
row[x * 24 + 8] = 255;
row[x * 24 + 16] = 255;
}
}
}
// Load the selection resources
selections = new Bitmap(640, 480);
selection = new Selection[8];
selection[0] = new Selection();
selection[0].Width = 640;
selection[0].Height = 480;
}