bmp.h 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. * This file is here to describe the fields in the header of
  30. * the BMP file. These fields are not used directly in Leptonica.
  31. * The only thing we use are the sizes of these two headers.
  32. * Furthermore, because of potential namespace conflicts with
  33. * the typedefs and defined sizes, we have changed the names
  34. * to protect anyone who may also need to use the original definitions.
  35. * Thanks to J. D. Bryan for pointing out the potential problems when
  36. * developing on Win32 compatible systems.
  37. */
  38. /*-------------------------------------------------------------*
  39. * BMP file header *
  40. *-------------------------------------------------------------*/
  41. struct BMP_FileHeader
  42. {
  43. l_int16 bfType; /* file type; must be "BM" */
  44. l_int16 bfSize; /* length of the file;
  45. sizeof(BMP_FileHeader) +
  46. sizeof(BMP_InfoHeader) +
  47. size of color table +
  48. size of DIB bits */
  49. l_int16 bfFill1; /* remainder of the bfSize field */
  50. l_int16 bfReserved1; /* don't care (set to 0)*/
  51. l_int16 bfReserved2; /* don't care (set to 0)*/
  52. l_int16 bfOffBits; /* offset from beginning of file */
  53. l_int16 bfFill2; /* remainder of the bfOffBits field */
  54. };
  55. typedef struct BMP_FileHeader BMP_FH;
  56. #define BMP_FHBYTES sizeof(BMP_FH)
  57. /*-------------------------------------------------------------*
  58. * BMP info header *
  59. *-------------------------------------------------------------*/
  60. struct BMP_InfoHeader
  61. {
  62. l_int32 biSize; /* size of the BMP_InfoHeader struct */
  63. l_int32 biWidth; /* bitmap width in pixels */
  64. l_int32 biHeight; /* bitmap height in pixels */
  65. l_int16 biPlanes; /* number of bitmap planes */
  66. l_int16 biBitCount; /* number of bits per pixel */
  67. l_int32 biCompression; /* compression format (0 == uncompressed) */
  68. l_int32 biSizeImage; /* size of image in bytes */
  69. l_int32 biXPelsPerMeter; /* pixels per meter in x direction */
  70. l_int32 biYPelsPerMeter; /* pixels per meter in y direction */
  71. l_int32 biClrUsed; /* number of colors used */
  72. l_int32 biClrImportant; /* number of important colors used */
  73. };
  74. typedef struct BMP_InfoHeader BMP_IH;
  75. #define BMP_IHBYTES sizeof(BMP_IH)
  76. #endif /* LEPTONICA_BMP_H */