public void Deserialize(ByteStream stream) { // Reserved, must be 0 : 2 bytes int reserved = stream.Read16(); if (reserved != 0) { throw new FormatException("Invalid ICONDIR reserved value"); } // Image type -> 1=ICO, 2=CUR : 2 bytes int type = stream.Read16(); switch (type) { case 1: this.Type = ICOType.ICO; break; case 2: this.Type = ICOType.CUR; break; default: throw new FormatException("Invalid ICONDIR type value"); } // Number of images : 2 bytes this.ImageCount = stream.Read16(); }
public ICONDIRENTRY(ICOType type, ICOImage image, int imageOffset) : this(type, new ICOImageInfo { Width = image.Width, Height = image.Height, HotspotX = image.HotspotX, HotspotY = image.HotspotY, BitsPerPixel = image.BitsPerPixel, Size = image.Serialized.Length, Offset = imageOffset }) { }
internal ICOImage(ICOType type, ICONDIRENTRY icondirentry, byte[] icoData) { byte[] imageData = Bytes.Subset(icoData, icondirentry.Image.Offset, icondirentry.Image.Size); if (BMP.isStrippedBMP(imageData)) { imageData = BMP.FromICO(icondirentry, imageData); this.Type = ICOImageType.BMP; } else { this.Type = ICOImageType.PNG; } MemoryStream stream = new MemoryStream(imageData); this.Image = new Bitmap(System.Drawing.Image.FromStream(stream)); this.HotspotX = icondirentry.Image.HotspotX; this.HotspotY = icondirentry.Image.HotspotY; }
public ICOFile(ICOType type) { this.Images = new List <ICOImage>(); this.Type = type; }
public void NewICO(ICOType type) { ico = new ICOFile(type); icoLoadedPath = null; RefreshAll(); }
public static byte[] Serialize(ICOType type, int imageCount) { return(new ICONDIR(type, imageCount).Serialize()); }
public ICONDIR(ICOType type, int imageCount) { this.Type = type; this.ImageCount = imageCount; }
public static byte[] Serialize(ICOType type, ICOImage image, int imageOffset) { return(new ICONDIRENTRY(type, image, imageOffset).Serialize()); }
public ICONDIRENTRY(ICOType type, byte[] data) : this(type, new ByteStream(data)) { }
public ICONDIRENTRY(ICOType type, ByteStream stream) { this.Type = type; this.Deserialize(stream); }
public ICONDIRENTRY(ICOType type, ICOImageInfo image) { this.Type = type; this.Image = image; }