public override Bitmap ConvertToBitmap(Sprite entity) { var data = entity.Data; var type = entity.Type; var size = entity.Width * entity.Height * (type == ColorBits.ARGB_8888 ? 4 : 2); if (entity.Compress == Compress.ZLIB) { data = Zlib.Decompress(data, size); } return(Bitmaps.FromArray(data, entity.Size, type)); }
void SetPixels(int[] pixels) { var len = image.Width * image.Height; var data = new byte[len * 4]; for (var i = 0; i < len; i++) { var pixel = pixels[i]; data[i * 4 + 0] = (byte)(pixel & 0xff); data[i * 4 + 1] = (byte)((pixel >> 8) & 0xff); data[i * 4 + 2] = (byte)((pixel >> 16) & 0xff); data[i * 4 + 3] = (byte)(pixel >> 24); } bitmap = Bitmaps.FromArray(data, image.Size); }
/// <summary> /// 读取一个贴图 /// </summary> /// <param name="stream"></param> /// <param name="entity"></param> /// <returns></returns> public static Bitmap ReadImage(Stream stream, Sprite entity) { var data = new byte[entity.Width * entity.Height * 4]; for (var i = 0; i < data.Length; i += 4) { var bits = entity.Type; if (entity.Version == ImgVersion.Ver4 && bits == ColorBits.ARGB_1555) { bits = ColorBits.ARGB_8888; } Colors.ReadColor(stream, bits, data, i); } return(Bitmaps.FromArray(data, entity.Size)); }
public override Bitmap ConvertToBitmap(Sprite entity) { var data = entity.Data; var type = entity.Type; var size = entity.Width * entity.Height * (type == ColorBits.ARGB_8888 ? 4 : 2); if (entity.Compress == Compress.ZLIB) { data = Zlib.Decompress(data, size); } using (var ms = new MemoryStream(data)) { data = new byte[entity.Size.Width * entity.Size.Height * 4]; for (var i = 0; i < data.Length; i += 4) { var temp = Colors.ReadColor(ms, type); temp.CopyTo(data, i); } } return(Bitmaps.FromArray(data, entity.Size)); }
public override Bitmap ConvertToBitmap(Sprite entity) { var data = entity.Data; var size = entity.Width * entity.Height; if (entity.Type == ColorBits.ARGB_1555 && entity.CompressMode == CompressMode.ZLIB) { data = Zlib.Decompress(data, size); var table = Album.CurrentTable; if (table.Count > 0) { using (var os = new MemoryStream()) { foreach (var i in data) { os.WriteColor(table[i % table.Count], ColorBits.ARGB_8888); } data = os.ToArray(); } return(Bitmaps.FromArray(data, entity.Size)); } } return(base.ConvertToBitmap(entity)); }
public override Bitmap ConvertToBitmap(Sprite entity) { var data = entity.Data; var size = entity.Width * entity.Height; if (entity.Compress == Compress.ZLIB) { data = Zlib.Decompress(data, size); var table = Album.CurrentTable; if (table.Count > 0) { using (var os = new MemoryStream()) { for (var i = 0; i < data.Length; i++) { var j = data[i] % table.Count; Colors.WriteColor(os, table[j], ColorBits.ARGB_8888); } data = os.ToArray(); } } } return(Bitmaps.FromArray(data, entity.Size)); }