2 * Copyright (c) 1999-2000 Image Power, Inc. and the University of
4 * Copyright (c) 2001-2002 Michael David Adams.
8 /* __START_OF_JASPER_LICENSE__
10 * JasPer License Version 2.0
12 * Copyright (c) 1999-2000 Image Power, Inc.
13 * Copyright (c) 1999-2000 The University of British Columbia
14 * Copyright (c) 2001-2003 Michael David Adams
16 * All rights reserved.
18 * Permission is hereby granted, free of charge, to any person (the
19 * "User") obtaining a copy of this software and associated documentation
20 * files (the "Software"), to deal in the Software without restriction,
21 * including without limitation the rights to use, copy, modify, merge,
22 * publish, distribute, and/or sell copies of the Software, and to permit
23 * persons to whom the Software is furnished to do so, subject to the
24 * following conditions:
26 * 1. The above copyright notices and this permission notice (which
27 * includes the disclaimer below) shall be included in all copies or
28 * substantial portions of the Software.
30 * 2. The name of a copyright holder shall not be used to endorse or
31 * promote products derived from the Software without specific prior
34 * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
35 * LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
36 * THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
37 * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
39 * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO
40 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
41 * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
42 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
43 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
44 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE
45 * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
46 * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
47 * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
48 * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
49 * PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS
50 * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
51 * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE
52 * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
53 * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
54 * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
55 * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
56 * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
57 * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
58 * RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
59 * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
61 * __END_OF_JASPER_LICENSE__
65 * Windows Bitmap File Library
67 * $Id: bmp_cod.h,v 1.1 2005/05/22 18:33:00 malaterre Exp $
73 /******************************************************************************\
75 \******************************************************************************/
77 #include "jasper/jas_types.h"
79 /******************************************************************************\
80 * Constants and macros.
81 \******************************************************************************/
83 #define BMP_MAGIC 0x4d42
84 /* The signature for a BMP file. */
87 /* The nominal header length. */
89 #define BMP_INFOLEN 40
90 /* The nominal info length. */
92 #define BMP_PALLEN(info) ((info)->numcolors * 4)
93 /* The length of the palette. */
95 #define BMP_HASPAL(info) ((info)->numcolors > 0)
96 /* Is this a palettized image? */
99 #define BMP_ENC_RGB 0 /* No special encoding. */
100 #define BMP_ENC_RLE8 1 /* Run length encoding. */
101 #define BMP_ENC_RLE4 2 /* Run length encoding. */
103 /******************************************************************************\
105 \******************************************************************************/
111 /* The signature (a.k.a. the magic number). */
114 /* The size of the file in 32-bit words. */
116 int_fast16_t reserved1;
117 /* Ask Bill Gates what this is all about. */
119 int_fast16_t reserved2;
123 /* The offset of the bitmap data from the bitmap file header in bytes. */
131 /* The red component. */
134 /* The green component. */
137 /* The blue component. */
148 /* The length of the bitmap information header in bytes. */
151 /* The width of the bitmap in pixels. */
154 /* The height of the bitmap in pixels. */
157 /* The bitmap data is specified in top-down order. */
159 int_fast16_t numplanes;
160 /* The number of planes. This must be set to a value of one. */
163 /* The number of bits per pixel. */
165 int_fast32_t enctype;
166 /* The type of compression used. */
169 /* The size of the image in bytes. */
172 /* The horizontal resolution in pixels/metre. */
175 /* The vertical resolution in pixels/metre. */
177 int_fast32_t numcolors;
178 /* The number of color indices used by the bitmap. */
180 int_fast32_t mincolors;
181 /* The number of color indices important for displaying the bitmap. */
183 bmp_palent_t *palents;
184 /* The colors should be listed in order of importance. */
188 /******************************************************************************\
189 * Functions and macros.
190 \******************************************************************************/
192 #define bmp_issupported(hdr, info) \
193 ((hdr)->magic == BMP_MAGIC && !(hdr)->reserved1 && \
194 !(hdr)->reserved2 && (info)->numplanes == 1 && \
195 ((info)->depth == 8 || (info)->depth == 24) && \
196 (info)->enctype == BMP_ENC_RGB)
197 /* Is this type of BMP file supported? */
199 #define bmp_haspal(info) \
201 /* Is there a palette? */
203 int bmp_numcmpts(bmp_info_t *info);
204 /* Get the number of components. */
206 bmp_info_t *bmp_info_create(void);
207 /* Create BMP information. */
209 void bmp_info_destroy(bmp_info_t *info);
210 /* Destroy BMP information. */
212 int bmp_isgrayscalepal(bmp_palent_t *palents, int numpalents);
213 /* Does the specified palette correspond to a grayscale image? */