public static Icon Create(byte[] colors, int width, int height, PixelFormat format) { if (format != PixelFormat.Format32bppArgb) { throw new NotImplementedException(); } ICONIMAGE image = new ICONIMAGE(width, height, colors); ICONDIR dir = new ICONDIR( new ICONDIRENTRY[] { new ICONDIRENTRY(image, 0) }); dir.Entries[0].ImageOffset = dir.Size; Icon icon; binaryWriter.BaseStream.Position = 0; dir.Write(binaryWriter); image.Write(binaryWriter); binaryWriter.BaseStream.Position = 0; icon = new Icon(binaryWriter.BaseStream); return(icon); }
public ICONDIRENTRY(ICONIMAGE image, int imageOffset) { Width = (byte)image.Header.Width; Height = (byte)(image.Header.Height >> 1); ColorCount = 0; Reserved = 0; Planes = image.Header.Planes; BitCount = image.Header.BitCount; BytesInRes = (uint)(image.Header.Size + image.Colors.Length + image.MaskSize + image.MaskSize); ImageOffset = (uint)imageOffset; }
public ICONDIRENTRY(ICONIMAGE image, int imageOffset) { this.Width = (byte)image.Header.Width; this.Height = (byte)(image.Header.Height >> 1); this.ColorCount = 0; this.Reserved = 0; this.Planes = image.Header.Planes; this.BitCount = image.Header.BitCount; this.BytesInRes = (uint)(image.Header.Size + image.Colors.Length + image.XOR.Length + image.AND.Length); this.ImageOffset = (uint)imageOffset; }
public static Icon Create(byte[] colors, int width, int height, PixelFormat format) { if (format != PixelFormat.Format32bppArgb) throw new NotImplementedException(); ICONIMAGE image = new ICONIMAGE(width, height, colors); ICONDIR dir = new ICONDIR( new ICONDIRENTRY[] { new ICONDIRENTRY(image, 0) } ); dir.Entries[0].ImageOffset = dir.Size; Icon icon; using (BinaryWriter bw = new BinaryWriter(new MemoryStream())) { dir.Write(bw); image.Write(bw); bw.BaseStream.Position = 0; icon = new Icon(bw.BaseStream); } return icon; }
public ICONDIRENTRY(ICONIMAGE image, int imageOffset) { this.Width = (byte)image.Header.Width; this.Height = (byte)(image.Header.Height >> 1); this.ColorCount = 0; this.Reserved = 0; this.Planes = image.Header.Planes; this.BitCount = image.Header.BitCount; this.BytesInRes = (uint)(image.Header.Size + image.Colors.Length + image.MaskSize + image.MaskSize); this.ImageOffset = (uint)imageOffset; }