public WORD Count; // How many images? /// <summary> /// Converts the current TAFactory.IconPack.IconDir into TAFactory.IconPack.GroupIconDir. /// </summary> /// <returns>TAFactory.IconPack.GroupIconDir</returns> public GroupIconDir ToGroupIconDir() { GroupIconDir grpDir = new GroupIconDir(); grpDir.Reserved = this.Reserved; grpDir.Type = this.Type; grpDir.Count = this.Count; return(grpDir); }
/// <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)); } }
public WORD Count; // How many images? #region Methods /// <summary> /// Converts the current TAFactory.IconPack.IconDir into TAFactory.IconPack.GroupIconDir. /// </summary> /// <returns>TAFactory.IconPack.GroupIconDir</returns> public GroupIconDir ToGroupIconDir() { GroupIconDir grpDir = new GroupIconDir(); grpDir.Reserved = this.Reserved; grpDir.Type = this.Type; grpDir.Count = this.Count; return grpDir; }