public static byte[] GetTransparentArrayFromFileWithDelete(string pathToFile) { byte[] newImage = new byte[0]; using (Bitmap bmp = new Bitmap(pathToFile)) { Color pixel = bmp.GetPixel(0, 0); Graphics graphics = Graphics.FromImage(bmp); Color backColor = bmp.GetPixel(1, 1); bmp.MakeTransparent(backColor); ImageConverter converter = new ImageConverter(); newImage = (byte[])converter.ConvertTo(bmp, typeof(byte[])); } try { File.Delete(pathToFile); } catch { } return newImage; }
Quote:The file remains locked until the Bitmap is disposed.
Dispose()
Bitmap
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)