tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ICOFileHeaders.h (2013B)


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