ICOFileHeaders.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #ifndef mozilla_image_ICOFileHeaders_h
  5. #define mozilla_image_ICOFileHeaders_h
  6. namespace mozilla {
  7. namespace image {
  8. #define ICONFILEHEADERSIZE 6
  9. #define ICODIRENTRYSIZE 16
  10. #define PNGSIGNATURESIZE 8
  11. #define BMPFILEHEADERSIZE 14
  12. /**
  13. * The header that comes right at the start of an icon file. (This
  14. * corresponds to the Windows ICONDIR structure.)
  15. */
  16. struct IconFileHeader
  17. {
  18. /**
  19. * Must be set to 0;
  20. */
  21. uint16_t mReserved;
  22. /**
  23. * 1 for icon (.ICO) image (or 2 for cursor (.CUR) image (icon with the
  24. * addition of a hotspot), but we don't support cursor).
  25. */
  26. uint16_t mType;
  27. /**
  28. * The number of BMP/PNG images contained in the icon file.
  29. */
  30. uint16_t mCount;
  31. };
  32. /**
  33. * For each BMP/PNG image that the icon file contains there must be a
  34. * corresponding icon dir entry. (This corresponds to the Windows
  35. * ICONDIRENTRY structure.) These entries are encoded directly after the
  36. * IconFileHeader.
  37. */
  38. struct IconDirEntry
  39. {
  40. uint8_t mWidth;
  41. uint8_t mHeight;
  42. /**
  43. * The number of colors in the color palette of the BMP/PNG that this dir
  44. * entry corresponds to, or 0 if the image does not use a color palette.
  45. */
  46. uint8_t mColorCount;
  47. /**
  48. * Should be set to 0.
  49. */
  50. uint8_t mReserved;
  51. union {
  52. uint16_t mPlanes; // ICO
  53. uint16_t mXHotspot; // CUR
  54. };
  55. union {
  56. uint16_t mBitCount; // ICO (bits per pixel)
  57. uint16_t mYHotspot; // CUR
  58. };
  59. /**
  60. * "bytes in resource" is the length of the encoded BMP/PNG that this dir
  61. * entry corresponds to.
  62. */
  63. uint32_t mBytesInRes;
  64. /**
  65. * The offset of the start of the encoded BMP/PNG that this dir entry
  66. * corresponds to (from the start of the icon file).
  67. */
  68. uint32_t mImageOffset;
  69. };
  70. } // namespace image
  71. } // namespace mozilla
  72. #endif // mozilla_image_ICOFileHeaders_h