Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
4.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: I C O M E R G E . H
  7. //
  8. // Contents: Utility functions for merging icons
  9. //
  10. // Notes:
  11. //
  12. // Author: jeffspr 18 Nov 1998
  13. //
  14. //----------------------------------------------------------------------------
  15. #ifndef _ICOMERGE_H_
  16. #define _ICOMERGE_H_
  17. #pragma once
  18. /****************************************************************************\
  19. * * FILE: Icons.H
  20. * * PURPOSE: IconPro Project Icon handling header file
  21. * * COMMENTS: *
  22. * * Copyright 1995 - 1998 Microsoft Corp. *
  23. * * History:
  24. * July '95 - Created
  25. * \****************************************************************************/
  26. /****************************************************************************/
  27. // Structs
  28. // These first two structs represent how the icon information is stored
  29. // when it is bound into a EXE or DLL file. Structure members are WORD
  30. // aligned and the last member of the structure is the ID instead of
  31. // the imageoffset.
  32. #pragma pack( push )
  33. #pragma pack( 2 )
  34. typedef struct
  35. {
  36. BYTE bWidth; // Width of the image
  37. BYTE bHeight; // Height of the image (times 2)
  38. BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
  39. BYTE bReserved; // Reserved
  40. WORD wPlanes; // Color Planes
  41. WORD wBitCount; // Bits per pixel
  42. DWORD dwBytesInRes; // how many bytes in this resource?
  43. WORD nID; // the ID
  44. } MEMICONDIRENTRY, *LPMEMICONDIRENTRY;
  45. typedef struct
  46. {
  47. WORD idReserved; // Reserved
  48. WORD idType; // resource type (1 for icons)
  49. WORD idCount; // how many images?
  50. MEMICONDIRENTRY idEntries[1]; // the entries for each image
  51. } MEMICONDIR, *LPMEMICONDIR;
  52. #pragma pack( pop )
  53. // These next two structs represent how the icon information is stored
  54. // in an ICO file.
  55. typedef struct
  56. {
  57. BYTE bWidth; // Width of the image
  58. BYTE bHeight; // Height of the image (times 2)
  59. BYTE bColorCount; // Number of colors in image (0 if >=8bpp)
  60. BYTE bReserved; // Reserved
  61. WORD wPlanes; // Color Planes
  62. WORD wBitCount; // Bits per pixel
  63. DWORD dwBytesInRes; // how many bytes in this resource?
  64. DWORD dwImageOffset; // where in the file is this image
  65. } ICONDIRENTRY, *LPICONDIRENTRY;
  66. typedef struct
  67. {
  68. WORD idReserved; // Reserved
  69. WORD idType; // resource type (1 for icons)
  70. WORD idCount; // how many images?
  71. ICONDIRENTRY idEntries[1]; // the entries for each image
  72. } ICONDIR, *LPICONDIR;
  73. // The following two structs are for the use of this program in
  74. // manipulating icons. They are more closely tied to the operation
  75. // of this program than the structures listed above. One of the
  76. // main differences is that they provide a pointer to the DIB
  77. // information of the masks.
  78. typedef struct
  79. {
  80. UINT Width, Height, Colors; // Width, Height and bpp
  81. LPBYTE lpBits; // ptr to DIB bits
  82. DWORD dwNumBytes; // how many bytes?
  83. LPBITMAPINFO lpbi; // ptr to header
  84. LPBYTE lpXOR; // ptr to XOR image bits
  85. LPBYTE lpAND; // ptr to AND image bits
  86. } ICONIMAGE, *LPICONIMAGE;
  87. typedef struct
  88. {
  89. BOOL bHasChanged; // Has image changed?
  90. WCHAR szOriginalICOFileName[MAX_PATH]; // Original name
  91. WCHAR szOriginalDLLFileName[MAX_PATH]; // Original name
  92. UINT nNumImages; // How many images?
  93. ICONIMAGE IconImages[1]; // Image entries
  94. } ICONRESOURCE, *LPICONRESOURCE;
  95. /****************************************************************************/
  96. /****************************************************************************/
  97. // Exported function prototypes
  98. LPICONRESOURCE ReadIconFromICOFile( PCWSTR szFileName );
  99. BOOL WriteIconToICOFile( LPICONRESOURCE lpIR, PCWSTR szFileName );
  100. HICON MakeIconFromResource( LPICONIMAGE lpIcon );
  101. LPICONRESOURCE ReadIconFromEXEFile( PCWSTR szFileName );
  102. BOOL IconImageToClipBoard( LPICONIMAGE lpii );
  103. BOOL IconImageFromClipBoard( LPICONIMAGE lpii, BOOL bStretchToFit );
  104. BOOL CreateBlankNewFormatIcon( LPICONIMAGE lpii );
  105. BOOL DrawXORMask( HDC hDC, RECT Rect, LPICONIMAGE lpIcon );
  106. BOOL DrawANDMask( HDC hDC, RECT Rect, LPICONIMAGE lpIcon );
  107. RECT GetXORImageRect( RECT Rect, LPICONIMAGE lpIcon );
  108. BOOL MakeNewANDMaskBasedOnPoint( LPICONIMAGE lpIcon, POINT pt );
  109. BOOL IconImageFromBMPFile( PCWSTR szFileName, LPICONIMAGE lpii, BOOL bStretchToFit );
  110. BOOL IconImageToBMPFile( PCWSTR szFileName, LPICONIMAGE lpii );
  111. VOID DebugPrintIconMasks(LPICONRESOURCE pIR);
  112. VOID OverlayIcons(LPICONRESOURCE pIR1, LPICONRESOURCE pIR2);
  113. LPICONRESOURCE ReadIconFromICOFile( PCWSTR szFileName );
  114. #endif // _ICOMERGE_H_