comparison mupdf-source/thirdparty/leptonica/src/bmp.h @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
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
27 #ifndef LEPTONICA_BMP_H
28 #define LEPTONICA_BMP_H
29
30 /*!
31 * \file bmp.h
32 *
33 * <pre>
34 * This file is here to describe the fields in the header of
35 * the BMP file. These fields are not used directly in Leptonica.
36 * The only thing we use are the sizes of these two headers.
37 * Furthermore, because of potential namespace conflicts with
38 * the typedefs and defined sizes, we have changed the names
39 * to protect anyone who may also need to use the original definitions.
40 * Thanks to J. D. Bryan for pointing out the potential problems when
41 * developing on Win32 compatible systems.
42 * </pre>
43 */
44
45 /*-------------------------------------------------------------*
46 * BMP file header *
47 *-------------------------------------------------------------*/
48
49 /*! BMP file header
50 *
51 * Notes:
52 * (1) The bfSize field is stored as a 32 bit integer and includes
53 * the size of the BMP_FileHeader, BMP_InfoHeader, the color
54 * table (if any), and the size of the DIB bits.
55 * (2) The bfOffBits field is also stored as a 32 bit integer and
56 * contains the absolute offset in bytes of the image data
57 * in this file. Some bmp files have additional data after the
58 * BMP_InfoHeader and before the color table (if it exists).
59 * However, enabling reading of these files makes the reader
60 * vulnerable to various malware attacks. Therefore we do not
61 * read bmp files with extra data, and require that the size
62 * of the color table in bytes is
63 * offset - sizeof(BMP_FileHeader) - sizeof(BMP_InfoHeader)
64 * (3) Use arrays of l_uint8[] to make an endianness agnostic
65 * access to the BMP_FileHeader easier.
66 */
67 struct BMP_FileHeader
68 {
69 l_uint8 bfType[2]; /*!< file type; must be "BM" */
70 l_uint8 bfSize[4]; /*!< length of the file;
71 sizeof(BMP_FileHeader) +
72 sizeof(BMP_InfoHeader) +
73 size of optional extra data +
74 size of color table +
75 size of DIB bits */
76 l_uint8 bfReserved1[2]; /*!< don't care (set to 0) */
77 l_uint8 bfReserved2[2]; /*!< don't care (set to 0) */
78 l_uint8 bfOffBits[4]; /*!< offset from beginning of file */
79 };
80 typedef struct BMP_FileHeader BMP_FH;
81
82 /*! Number of bytes in a BMP file header */
83 #define BMP_FHBYTES sizeof(BMP_FH)
84
85
86 /*-------------------------------------------------------------*
87 * BMP info header *
88 *-------------------------------------------------------------*/
89
90 /*! BMP info header */
91 struct BMP_InfoHeader
92 {
93 l_int32 biSize; /*!< size of the BMP_InfoHeader struct */
94 l_int32 biWidth; /*!< bitmap width in pixels */
95 l_int32 biHeight; /*!< bitmap height in pixels */
96 l_int16 biPlanes; /*!< number of bitmap planes */
97 l_int16 biBitCount; /*!< number of bits per pixel */
98 l_int32 biCompression; /*!< compress format (0 == uncompressed) */
99 l_int32 biSizeImage; /*!< size of image in bytes */
100 l_int32 biXPelsPerMeter; /*!< pixels per meter in x direction */
101 l_int32 biYPelsPerMeter; /*!< pixels per meter in y direction */
102 l_int32 biClrUsed; /*!< number of colors used */
103 l_int32 biClrImportant; /*!< number of important colors used */
104 };
105 typedef struct BMP_InfoHeader BMP_IH;
106
107 /*! Number of bytes in a BMP info header */
108 #define BMP_IHBYTES sizeof(BMP_IH)
109
110 #endif /* LEPTONICA_BMP_H */