Saving alpha channel in Tiff files

davidko

New member
Joined
Dec 9, 2003
Messages
1
Hello, this seems like it should be a simple process, but when I try and save a tiff file with rgba, it does not save the way I expect it to. I create a Bitmap object with 32 bit rgba, draw on it via Graphics object, and then save the bitmap with the tiff parameters, but when I open the file in photoshop, there is only black where it should be transparent. Here is the code Im using:

Code:
// set up bitmap object
System.Drawing.Bitmap bm = new System.Drawing.Bitmap(imagewidth, imageheight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bm);
g.Clear(System.Drawing.Color.FromArgb(0, System.Drawing.Color.Black));

// draw on the Graphics object....



// save file
EncoderParameters parms = new EncoderParameters();
parms.Param = new EncoderParameter[3];
parms.Param[0] = new EncoderParameter(Encoder.ColorDepth, 32L);
parms.Param[1] = new EncoderParameter(Encoder.Compression, (long)EncoderValue.CompressionLZW);
parms.Param[2] = new EncoderParameter(Encoder.Version, 5);
directory.TrimEnd("\\".ToCharArray());

bm.Save(directory + "\\saveimage.tif", GetEncoderInfo(ImageFormat.Tiff), parms);

Does anyone know if saving tiffs in .net (v1.1) with alpha channels even works. Im guessing the pixels are being premultiplied with the alpha values, but thats not what I want. Any help would be appreciated.
 
Back
Top