示例#1
0
        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();
        }
示例#2
0
 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
 })
 {
 }
示例#3
0
        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;
        }
示例#4
0
 public ICOFile(ICOType type)
 {
     this.Images = new List <ICOImage>();
     this.Type   = type;
 }
示例#5
0
 public void NewICO(ICOType type)
 {
     ico           = new ICOFile(type);
     icoLoadedPath = null;
     RefreshAll();
 }
示例#6
0
 public static byte[] Serialize(ICOType type, int imageCount)
 {
     return(new ICONDIR(type, imageCount).Serialize());
 }
示例#7
0
 public ICONDIR(ICOType type, int imageCount)
 {
     this.Type       = type;
     this.ImageCount = imageCount;
 }
示例#8
0
 public static byte[] Serialize(ICOType type, ICOImage image, int imageOffset)
 {
     return(new ICONDIRENTRY(type, image, imageOffset).Serialize());
 }
示例#9
0
 public ICONDIRENTRY(ICOType type, byte[] data) : this(type, new ByteStream(data))
 {
 }
示例#10
0
 public ICONDIRENTRY(ICOType type, ByteStream stream)
 {
     this.Type = type;
     this.Deserialize(stream);
 }
示例#11
0
 public ICONDIRENTRY(ICOType type, ICOImageInfo image)
 {
     this.Type  = type;
     this.Image = image;
 }