views:

99

answers:

2

Hi, i simply want to load a .BMP file and get the Bitmap object in 24bit RGB format (or 32bit in RGB format).

All methods I tried return a Bitmap/Image object with PixelFormat = Format32bppArgb. Even if of course BMPs don't have alpha.

new Bitmap(System.Drawing.Image.FromFile(fileName, true));
new Bitmap(fileName);

I currently solve the problem by copying the first object to another in memory bitmap at 24bit RBG.

Is there a single method to do it?

Thanks

A: 

Exactly what do you mean by copying the first object to another?

To achieve what you want to do, meaning loading an image and converting it to 24 bit, just get the graphics context of a second bitmap that matches the size and that is RGB, and paint the original bitmap onto this one.

Pedery
A: 

You can clone it to a RGB format one:

var bitmapInRgbFormat = loadedBitmap.Clone(new Rectangle(0, 0, loadedBitmap.Width, loadedBitmap.Height), PixelFormat.Format32bppRgb)
Dudu