My problem is that i want to make an image background transparent. And the following function works fine for me but while testing on a different machine I found out that there are a lot of artifact colors and the transparency is not as clear as it is on my machine and some other machines. I was working with the debug build and the test was done on release build. But even with release build we see different results on different machines.
Image CreateTransparentBackgroundImage(Image image)
{
using (Bitmap tempBitmap = new Bitmap(image.Width, image.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb))
{
var g = Graphics.FromImage(tempBitmap);
Rectangle rec = new Rectangle(0 ,0,image.Width, image.Height);
g.DrawImage(image,rec, 0, 0,image.Width,image.Height, GraphicsUnit.Pixel);
tempBitmap.MakeTransparent(System.Drawing.Color.White);
g.Dispose();
return (Image)tempBitmap.Clone();
}
}
Any help would be really appreciated.