protected static Bitmap decode(byte[] image) { TgaData tga = new TgaData(image); Bitmap bitmap = new Bitmap(tga.Width, tga.Height); for (int y = 0; y < tga.Height; ++y) { for (int x = 0; x < tga.Width; ++x) { bitmap.SetPixel(x, y, Color.FromArgb(tga.GetPixel(x, y))); } } return(bitmap); }
private static Bitmap Decode(byte[] image) { TgaData tga = new TgaData(image); Bitmap bitmap = new Bitmap(tga.Width, tga.Height); for (int y = 0; y < tga.Height; ++y) { for (int x = 0; x < tga.Width; ++x) { if (tga.GetPixel(x, y) == 16777215) { } bitmap.SetPixel(x, y, System.DrawingCore.Color.FromArgb(tga.GetPixel(x, y))); } } return(bitmap); }
private static Image Decode(byte[] image) { TgaData tga = new TgaData(image); var bitmap = new Image <Argb32>(tga.Width, tga.Height); for (int y = 0; y < tga.Height; ++y) { for (int x = 0; x < tga.Width; ++x) { unchecked { bitmap[x, y] = new Argb32((uint)tga.GetPixel(x, y)); } } } return(bitmap); }
protected static byte[] decode(byte[] image) { TgaData tga = new TgaData(image); //return tga.ColorData; //Bitmap bitmap = new Bitmap(tga.Width, tga.Height); using MemoryStream memoryStream = new MemoryStream(); for (int y = 0; y < tga.Height; ++y) { for (int x = 0; x < tga.Width; ++x) { //bitmap.SetPixel(x, y, Color.FromArgb(tga.GetPixel(x, y))); memoryStream.WriteAsync(BitConverter.GetBytes(tga.GetPixel(x, y))); } } return(memoryStream.ToArray()); }
public static TgaData FromFile(string path) { try { using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read)) { int length = (int)fs.Length; byte[] buffer = new byte[length]; fs.Read(buffer, 0, length); TgaData tgaData = new TgaData(buffer); tgaData.pixles = decode(buffer); return(tgaData); //return decode(buffer); } } catch (Exception) { return(null); } }