bmp.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*====================================================================*
  2. - Copyright (C) 2001 Leptonica. All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions
  6. - are met:
  7. - 1. Redistributions of source code must retain the above copyright
  8. - notice, this list of conditions and the following disclaimer.
  9. - 2. Redistributions in binary form must reproduce the above
  10. - copyright notice, this list of conditions and the following
  11. - disclaimer in the documentation and/or other materials
  12. - provided with the distribution.
  13. -
  14. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  15. - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  16. - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
  18. - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  19. - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20. - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  21. - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  22. - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  23. - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. *====================================================================*/
  26. #ifndef LEPTONICA_BMP_H
  27. #define LEPTONICA_BMP_H
  28. /*!
  29. * \file bmp.h
  30. *
  31. * <pre>
  32. * This file is here to describe the fields in the header of
  33. * the BMP file. These fields are not used directly in Leptonica.
  34. * The only thing we use are the sizes of these two headers.
  35. * Furthermore, because of potential namespace conflicts with
  36. * the typedefs and defined sizes, we have changed the names
  37. * to protect anyone who may also need to use the original definitions.
  38. * Thanks to J. D. Bryan for pointing out the potential problems when
  39. * developing on Win32 compatible systems.
  40. * </pre>
  41. */
  42. /*-------------------------------------------------------------*
  43. * BMP file header *
  44. *-------------------------------------------------------------*/
  45. /*! BMP file header */
  46. struct BMP_FileHeader
  47. {
  48. l_int16 bfType; /*!< file type; must be "BM" */
  49. l_int16 bfSize; /*!< length of the file;
  50. sizeof(BMP_FileHeader) +
  51. sizeof(BMP_InfoHeader) +
  52. size of color table +
  53. size of DIB bits */
  54. l_int16 bfFill1; /*!< remainder of the bfSize field */
  55. l_int16 bfReserved1; /*!< don't care (set to 0) */
  56. l_int16 bfReserved2; /*!< don't care (set to 0) */
  57. l_int16 bfOffBits; /*!< offset from beginning of file */
  58. l_int16 bfFill2; /*!< remainder of the bfOffBits field */
  59. };
  60. typedef struct BMP_FileHeader BMP_FH;
  61. /*! Number of bytes in a BMP file header */
  62. #define BMP_FHBYTES sizeof(BMP_FH)
  63. /*-------------------------------------------------------------*
  64. * BMP info header *
  65. *-------------------------------------------------------------*/
  66. /*! BMP info header */
  67. struct BMP_InfoHeader
  68. {
  69. l_int32 biSize; /*!< size of the BMP_InfoHeader struct */
  70. l_int32 biWidth; /*!< bitmap width in pixels */
  71. l_int32 biHeight; /*!< bitmap height in pixels */
  72. l_int16 biPlanes; /*!< number of bitmap planes */
  73. l_int16 biBitCount; /*!< number of bits per pixel */
  74. l_int32 biCompression; /*!< compress format (0 == uncompressed) */
  75. l_int32 biSizeImage; /*!< size of image in bytes */
  76. l_int32 biXPelsPerMeter; /*!< pixels per meter in x direction */
  77. l_int32 biYPelsPerMeter; /*!< pixels per meter in y direction */
  78. l_int32 biClrUsed; /*!< number of colors used */
  79. l_int32 biClrImportant; /*!< number of important colors used */
  80. };
  81. typedef struct BMP_InfoHeader BMP_IH;
  82. /*! Number of bytes in a BMP info header */
  83. #define BMP_IHBYTES sizeof(BMP_IH)
  84. #endif /* LEPTONICA_BMP_H */