I'm trying to resize an RGB 8-Bit Tif and maintain it's transparency in c#. I've tried the following code.
using (Image thumbnail = new Bitmap(1500, 1500))
{
using (Bitmap source = new Bitmap(@"c:\trans.tif"))
{
using (Graphics g = Graphics.FromImage(thumbnail))
{
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.Clear(Color.Transparent);
g.DrawImage(source, 0, 0, 1500, 1500);
}
}
thumbnail.Save(@"c:\testoutput.tif", ImageFormat.Tiff);
//using (MemoryStream ms = new MemoryStream())
//{
// //thumbnail.Save(ms, ImageFormat.Tiff);
// //
// //result = ms.ToArray();
//}
}
The image was created using photoshop and I can't figure out why it's not holding the transparency on the resized tiffs.
Any ideas?