コード例 #1
0
        public DWORD ImageOffset;    // Where in the file is this image?

        /// <summary>
        /// Converts the current TAFactory.IconPack.IconDirEntry into TAFactory.IconPack.GroupIconDirEntry.
        /// </summary>
        /// <param name="id">The resource identifier.</param>
        /// <returns>TAFactory.IconPack.GroupIconDirEntry</returns>
        public GroupIconDirEntry ToGroupIconDirEntry(int id)
        {
            GroupIconDirEntry grpEntry = new GroupIconDirEntry();

            grpEntry.Width      = this.Width;
            grpEntry.Height     = this.Height;
            grpEntry.ColorCount = this.ColorCount;
            grpEntry.Reserved   = this.Reserved;
            grpEntry.Planes     = this.Planes;
            grpEntry.BitCount   = this.BitCount;
            grpEntry.BytesInRes = this.BytesInRes;
            grpEntry.ID         = (short)id;
            return(grpEntry);
        }
コード例 #2
0
        /// <summary>
        /// Gets a System.Drawing.Icon that represents RT_GROUP_ICON at the givin index from the executable module.
        /// </summary>
        /// <param name="index">The index of the RT_GROUP_ICON in the executable module.</param>
        /// <returns>Returns System.Drawing.Icon.</returns>
        private Icon GetIconFromLib(int index)
        {
            byte[] resourceData = GetResourceData(this.ModuleHandle, this.IconNamesList[index], ResourceTypes.RT_GROUP_ICON);
            //Convert the resouce into an .ico file image.
            using (MemoryStream inputStream = new MemoryStream(resourceData))
                using (MemoryStream destStream = new MemoryStream())
                {
                    //Read the GroupIconDir header.
                    GroupIconDir grpDir = Utility.ReadStructure <GroupIconDir>(inputStream);

                    int numEntries      = grpDir.Count;
                    int iconImageOffset = IconInfo.SizeOfIconDir + numEntries * IconInfo.SizeOfIconDirEntry;

                    //Write the IconDir header.
                    Utility.WriteStructure <IconDir>(destStream, grpDir.ToIconDir());
                    for (int i = 0; i < numEntries; i++)
                    {
                        //Read the GroupIconDirEntry.
                        GroupIconDirEntry grpEntry = Utility.ReadStructure <GroupIconDirEntry>(inputStream);

                        //Write the IconDirEntry.
                        destStream.Seek(IconInfo.SizeOfIconDir + i * IconInfo.SizeOfIconDirEntry, SeekOrigin.Begin);
                        Utility.WriteStructure <IconDirEntry>(destStream, grpEntry.ToIconDirEntry(iconImageOffset));

                        //Get the icon image raw data and write it to the stream.
                        byte[] imgBuf = GetResourceData(this.ModuleHandle, grpEntry.ID, ResourceTypes.RT_ICON);
                        destStream.Seek(iconImageOffset, SeekOrigin.Begin);
                        destStream.Write(imgBuf, 0, imgBuf.Length);

                        //Append the iconImageOffset.
                        iconImageOffset += imgBuf.Length;
                    }
                    destStream.Seek(0, SeekOrigin.Begin);
                    return(new Icon(destStream));
                }
        }
コード例 #3
0
ファイル: IconDir.cs プロジェクト: 450640526/HtmExplorer
        public DWORD ImageOffset; // Where in the file is this image?

        #region Methods

        /// <summary>
        /// Converts the current TAFactory.IconPack.IconDirEntry into TAFactory.IconPack.GroupIconDirEntry.
        /// </summary>
        /// <param name="id">The resource identifier.</param>
        /// <returns>TAFactory.IconPack.GroupIconDirEntry</returns>
        public GroupIconDirEntry ToGroupIconDirEntry(int id)
        {
            GroupIconDirEntry grpEntry = new GroupIconDirEntry();
            grpEntry.Width = this.Width;
            grpEntry.Height = this.Height;
            grpEntry.ColorCount = this.ColorCount;
            grpEntry.Reserved = this.Reserved;
            grpEntry.Planes = this.Planes;
            grpEntry.BitCount = this.BitCount;
            grpEntry.BytesInRes = this.BytesInRes;
            grpEntry.ID = (short)id;
            return grpEntry;
        }