I am trying to resize an 8-bit TIF RGB and maintain its transparency in C #. I 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);
}
The image was created using Photoshop, and I can’t understand why it does not hold the transparency on the resized.
Any ideas?
source
share