How to cause .NET to save a TIFF in PARGB32 format?

108 Views Asked by At

I have created a bitmap in PARGB32 format. I realize PNG cannot store premultiplied alpha (at least, marked as such), but I believe TIFF can. How can I force .NET to save a TIFF in PARGB32 format? By default, it appears to load back as AGRB32, even if the bitmap being saved is in PARGB32 format.

1

There are 1 best solutions below

0
Daniel Kravetz Malabud On

Based on the MSDN documentation you could use the PixelFormat enum.

A quick and dirty example could be:

var converted = new Bitmap(bmp.Width, bmp.Height, PixelFormat.Format32bppPArgb);
using (var g = Graphics.FromImage(converted))
{
    g.DrawImage(bmp, 0, 0);
}
IntPtr menuBmp = bmp.GetHbitmap();

This is assuming a variable called bmp hold the image.