public static byte[] GetTransparentArrayFromFileWithDelete(string pathToFile) { byte[] newImage = new byte[0]; error = string.Empty; using (Bitmap bmp = new Bitmap(pathToFile)) { Color pixel = bmp.GetPixel(0, 0); if (pixel.A != 0) { // Make backColor transparent for myBitmap. bmp.MakeTransparent(Color.Transparent); ImageConverter converter = new ImageConverter(); newImage = (byte[])converter.ConvertTo(bmp, typeof(byte[])); bmp.Dispose(); } else { FileStream fs = new FileStream(pathToFile, FileMode.OpenOrCreate, FileAccess.Read); newImage = new byte[fs.Length]; fs.Read(newImage, 0, System.Convert.ToInt32(fs.Length)); fs.Close(); } } try { File.Delete(pathToFile); } catch { } return newImage; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)