Leptonica  1.73
Image processing and image analysis suite
bmpio.c
Go to the documentation of this file.
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 
42 #ifdef HAVE_CONFIG_H
43 #include "config_auto.h"
44 #endif /* HAVE_CONFIG_H */
45 
46 #include <string.h>
47 #include "allheaders.h"
48 #include "bmp.h"
49 
50 /* --------------------------------------------*/
51 #if USE_BMPIO /* defined in environ.h */
52 /* --------------------------------------------*/
53 
54  /* Here we're setting the pixel value 0 to white (255) and the
55  * value 1 to black (0). This is the convention for grayscale, but
56  * the opposite of the convention for 1 bpp, where 0 is white
57  * and 1 is black. Both colormap entries are opaque (alpha = 255) */
58 RGBA_QUAD bwmap[2] = { {255,255,255,255}, {0,0,0,255} };
59 
60  /* Colormap size limit */
61 static const l_int32 L_MAX_ALLOWED_NUM_COLORS = 256;
62 
63  /* Image dimension limits */
64 static const l_int32 L_MAX_ALLOWED_WIDTH = 1000000;
65 static const l_int32 L_MAX_ALLOWED_HEIGHT = 1000000;
66 static const l_int64 L_MAX_ALLOWED_PIXELS = 400000000LL;
67 
68 #ifndef NO_CONSOLE_IO
69 #define DEBUG 0
70 #endif /* ~NO_CONSOLE_IO */
71 
72 /*--------------------------------------------------------------*
73  * Read bmp *
74  *--------------------------------------------------------------*/
88 PIX *
90 {
91 l_uint8 *data;
92 size_t size;
93 PIX *pix;
94 
95  PROCNAME("pixReadStreamBmp");
96 
97  if (!fp)
98  return (PIX *)ERROR_PTR("fp not defined", procName, NULL);
99 
100  /* Read data from file and decode into Y,U,V arrays */
101  rewind(fp);
102  if ((data = l_binaryReadStream(fp, &size)) == NULL)
103  return (PIX *)ERROR_PTR("data not read", procName, NULL);
104 
105  pix = pixReadMemBmp(data, size);
106  LEPT_FREE(data);
107  return pix;
108 }
109 
110 
118 PIX *
119 pixReadMemBmp(const l_uint8 *cdata,
120  size_t size)
121 {
122 l_uint8 pel[4];
123 l_uint8 *cmapBuf, *fdata, *data;
124 l_int16 bftype, offset, depth, d;
125 l_int32 width, height, xres, yres, compression, imagebytes;
126 l_int32 cmapbytes, cmapEntries;
127 l_int32 fdatabpl, extrabytes, pixWpl, pixBpl, i, j, k;
128 l_uint32 *line, *pixdata, *pword;
129 l_int64 npixels;
130 BMP_FH *bmpfh;
131 BMP_IH *bmpih;
132 PIX *pix, *pix1;
133 PIXCMAP *cmap;
134 
135  PROCNAME("pixReadMemBmp");
136 
137  if (!cdata)
138  return (PIX *)ERROR_PTR("cdata not defined", procName, NULL);
139  if (size < sizeof(BMP_FH) + sizeof(BMP_IH))
140  return (PIX *)ERROR_PTR("bmf size error", procName, NULL);
141 
142  /* Verify this is an uncompressed bmp */
143  bmpfh = (BMP_FH *)cdata;
144  bftype = convertOnBigEnd16(bmpfh->bfType);
145  if (bftype != BMP_ID)
146  return (PIX *)ERROR_PTR("not bmf format", procName, NULL);
147  bmpih = (BMP_IH *)(cdata + BMP_FHBYTES);
148  if (!bmpih)
149  return (PIX *)ERROR_PTR("bmpih not defined", procName, NULL);
150  compression = convertOnBigEnd32(bmpih->biCompression);
151  if (compression != 0)
152  return (PIX *)ERROR_PTR("cannot read compressed BMP files",
153  procName, NULL);
154 
155  /* Read the rest of the useful header information */
156  offset = convertOnBigEnd16(bmpfh->bfOffBits);
157  width = convertOnBigEnd32(bmpih->biWidth);
158  height = convertOnBigEnd32(bmpih->biHeight);
159  depth = convertOnBigEnd16(bmpih->biBitCount);
160  imagebytes = convertOnBigEnd32(bmpih->biSizeImage);
161  xres = convertOnBigEnd32(bmpih->biXPelsPerMeter);
162  yres = convertOnBigEnd32(bmpih->biYPelsPerMeter);
163 
164  /* Some sanity checking. We impose limits on the image
165  * dimensions and number of pixels. We make sure the file
166  * is the correct size to hold the amount of uncompressed data
167  * that is specified in the header. The number of colormap
168  * entries is checked: it can be either 0 (no cmap) or some
169  * number between 2 and 256.
170  * Note that the imagebytes for uncompressed images is either
171  * 0 or the size of the file data. (The fact that it can
172  * be 0 is perhaps some legacy glitch). */
173  if (width < 1)
174  return (PIX *)ERROR_PTR("width < 1", procName, NULL);
175  if (width > L_MAX_ALLOWED_WIDTH)
176  return (PIX *)ERROR_PTR("width too large", procName, NULL);
177  if (height < 1)
178  return (PIX *)ERROR_PTR("height < 1", procName, NULL);
179  if (height > L_MAX_ALLOWED_HEIGHT)
180  return (PIX *)ERROR_PTR("height too large", procName, NULL);
181  npixels = 1LL * width * height;
182  if (npixels > L_MAX_ALLOWED_PIXELS)
183  return (PIX *)ERROR_PTR("npixels too large", procName, NULL);
184  if (depth != 1 && depth != 2 && depth != 4 && depth != 8 &&
185  depth != 16 && depth != 24 && depth != 32)
186  return (PIX *)ERROR_PTR("depth not in {1, 2, 4, 8, 16, 24, 32}",
187  procName,NULL);
188  fdatabpl = 4 * ((1LL * width * depth + 31)/32);
189  if (imagebytes != 0 && imagebytes != fdatabpl * height)
190  return (PIX *)ERROR_PTR("invalid imagebytes", procName, NULL);
191  cmapbytes = offset - BMP_FHBYTES - BMP_IHBYTES;
192  cmapEntries = cmapbytes / sizeof(RGBA_QUAD);
193  if (cmapEntries < 0 || cmapEntries == 1)
194  return (PIX *)ERROR_PTR("invalid: cmap size < 0 or 1", procName, NULL);
195  if (cmapEntries > L_MAX_ALLOWED_NUM_COLORS)
196  return (PIX *)ERROR_PTR("invalid cmap: too large", procName,NULL);
197  if (size != 1LL * offset + 1LL * fdatabpl * height)
198  return (PIX *)ERROR_PTR("size incommensurate with image data",
199  procName,NULL);
200 
201  /* Handle the colormap */
202  cmapBuf = NULL;
203  if (cmapEntries > 0) {
204  if ((cmapBuf = (l_uint8 *)LEPT_CALLOC(cmapEntries, sizeof(RGBA_QUAD)))
205  == NULL)
206  return (PIX *)ERROR_PTR("cmapBuf alloc fail", procName, NULL );
207 
208  /* Read the colormap entry data from bmp. The RGBA_QUAD colormap
209  * entries are used for both bmp and leptonica colormaps. */
210  memcpy(cmapBuf, cdata + BMP_FHBYTES + BMP_IHBYTES,
211  sizeof(RGBA_QUAD) * cmapEntries);
212  }
213 
214  /* Make a 32 bpp pix if depth is 24 bpp */
215  d = (depth == 24) ? 32 : depth;
216  if ((pix = pixCreate(width, height, d)) == NULL) {
217  LEPT_FREE(cmapBuf);
218  return (PIX *)ERROR_PTR( "pix not made", procName, NULL);
219  }
220  pixSetXRes(pix, (l_int32)((l_float32)xres / 39.37 + 0.5)); /* to ppi */
221  pixSetYRes(pix, (l_int32)((l_float32)yres / 39.37 + 0.5)); /* to ppi */
222  pixSetInputFormat(pix, IFF_BMP);
223  pixWpl = pixGetWpl(pix);
224  pixBpl = 4 * pixWpl;
225 
226  /* Convert the bmp colormap to a pixcmap */
227  cmap = NULL;
228  if (cmapEntries > 0) { /* import the colormap to the pix cmap */
229  cmap = pixcmapCreate(L_MIN(d, 8));
230  LEPT_FREE(cmap->array); /* remove generated cmap array */
231  cmap->array = (void *)cmapBuf; /* and replace */
232  cmap->n = L_MIN(cmapEntries, 256);
233  for (i = 0; i < cmap->n; i++) /* set all colors opaque */
234  pixcmapSetAlpha (cmap, i, 255);
235  }
236  pixSetColormap(pix, cmap);
237 
238  /* Acquire the image data. Image origin for bmp is at lower right. */
239  fdata = (l_uint8 *)cdata + offset; /* start of the bmp image data */
240  pixdata = pixGetData(pix);
241  if (depth != 24) { /* typ. 1 or 8 bpp */
242  data = (l_uint8 *)pixdata + pixBpl * (height - 1);
243  for (i = 0; i < height; i++) {
244  memcpy(data, fdata, fdatabpl);
245  fdata += fdatabpl;
246  data -= pixBpl;
247  }
248  } else { /* 24 bpp file; 32 bpp pix
249  * Note: for bmp files, pel[0] is blue, pel[1] is green,
250  * and pel[2] is red. This is opposite to the storage
251  * in the pix, which puts the red pixel in the 0 byte,
252  * the green in the 1 byte and the blue in the 2 byte.
253  * Note also that all words are endian flipped after
254  * assignment on L_LITTLE_ENDIAN platforms.
255  *
256  * We can then make these assignments for little endians:
257  * SET_DATA_BYTE(pword, 1, pel[0]); blue
258  * SET_DATA_BYTE(pword, 2, pel[1]); green
259  * SET_DATA_BYTE(pword, 3, pel[2]); red
260  * This looks like:
261  * 3 (R) 2 (G) 1 (B) 0
262  * |-----------|------------|-----------|-----------|
263  * and after byte flipping:
264  * 3 2 (B) 1 (G) 0 (R)
265  * |-----------|------------|-----------|-----------|
266  *
267  * For big endians we set:
268  * SET_DATA_BYTE(pword, 2, pel[0]); blue
269  * SET_DATA_BYTE(pword, 1, pel[1]); green
270  * SET_DATA_BYTE(pword, 0, pel[2]); red
271  * This looks like:
272  * 0 (R) 1 (G) 2 (B) 3
273  * |-----------|------------|-----------|-----------|
274  * so in both cases we get the correct assignment in the PIX.
275  *
276  * Can we do a platform-independent assignment?
277  * Yes, set the bytes without using macros:
278  * *((l_uint8 *)pword) = pel[2]; red
279  * *((l_uint8 *)pword + 1) = pel[1]; green
280  * *((l_uint8 *)pword + 2) = pel[0]; blue
281  * For little endians, before flipping, this looks again like:
282  * 3 (R) 2 (G) 1 (B) 0
283  * |-----------|------------|-----------|-----------|
284  */
285  extrabytes = fdatabpl - 3 * width;
286  line = pixdata + pixWpl * (height - 1);
287  for (i = 0; i < height; i++) {
288  for (j = 0; j < width; j++) {
289  pword = line + j;
290  memcpy(&pel, fdata, 3);
291  fdata += 3;
292  *((l_uint8 *)pword + COLOR_RED) = pel[2];
293  *((l_uint8 *)pword + COLOR_GREEN) = pel[1];
294  *((l_uint8 *)pword + COLOR_BLUE) = pel[0];
295  }
296  if (extrabytes) {
297  for (k = 0; k < extrabytes; k++) {
298  memcpy(&pel, fdata, 1);
299  fdata++;
300  }
301  }
302  line -= pixWpl;
303  }
304  }
305 
306  pixEndianByteSwap(pix);
307 
308  /* ----------------------------------------------
309  * The bmp colormap determines the values of black
310  * and white pixels for binary in the following way:
311  * (a) white = 0 [255], black = 1 [0]
312  * 255, 255, 255, 255, 0, 0, 0, 255
313  * (b) black = 0 [0], white = 1 [255]
314  * 0, 0, 0, 255, 255, 255, 255, 255
315  * We have no need for a 1 bpp pix with a colormap!
316  * Note: the alpha component here is 255 (opaque)
317  * ---------------------------------------------- */
318  if (depth == 1 && cmap) {
320  pixDestroy(&pix);
321  pix = pix1; /* rename */
322  }
323 
324  return pix;
325 }
326 
327 
328 /*--------------------------------------------------------------*
329  * Write bmp *
330  *--------------------------------------------------------------*/
338 l_int32
340  PIX *pix)
341 {
342 l_uint8 *data;
343 size_t size, nbytes;
344 
345  PROCNAME("pixWriteStreamBmp");
346 
347  if (!fp)
348  return ERROR_INT("stream not defined", procName, 1);
349  if (!pix)
350  return ERROR_INT("pix not defined", procName, 1);
351 
352  pixWriteMemBmp(&data, &size, pix);
353  rewind(fp);
354  nbytes = fwrite(data, 1, size, fp);
355  free(data);
356  if (nbytes != size)
357  return ERROR_INT("Write error", procName, 1);
358  return 0;
359 }
360 
361 
383 l_int32
384 pixWriteMemBmp(l_uint8 **pfdata,
385  size_t *pfsize,
386  PIX *pixs)
387 {
388 l_uint8 pel[4];
389 l_uint8 *cta = NULL; /* address of the bmp color table array */
390 l_uint8 *fdata, *data, *fmdata;
391 l_int32 cmaplen; /* number of bytes in the bmp colormap */
392 l_int32 ncolors, val, stepsize;
393 l_int32 w, h, d, fdepth, xres, yres;
394 l_int32 pixWpl, pixBpl, extrabytes, fBpl, fWpl, i, j, k;
395 l_int32 heapcm; /* extra copy of cta on the heap ? 1 : 0 */
396 l_uint32 offbytes, fimagebytes;
397 l_uint32 *line, *pword;
398 size_t fsize;
399 BMP_FH *bmpfh;
400 BMP_IH *bmpih;
401 PIX *pix;
402 PIXCMAP *cmap;
403 RGBA_QUAD *pquad;
404 
405  PROCNAME("pixWriteMemBmp");
406 
407  if (pfdata) *pfdata = NULL;
408  if (pfsize) *pfsize = 0;
409  if (!pfdata)
410  return ERROR_INT("&fdata not defined", procName, 1 );
411  if (!pfsize)
412  return ERROR_INT("&fsize not defined", procName, 1 );
413  if (!pixs)
414  return ERROR_INT("pixs not defined", procName, 1);
415 
416  pixGetDimensions(pixs, &w, &h, &d);
417  if (d == 2) {
418  L_WARNING("2 bpp files can't be read; converting to 8 bpp\n", procName);
419  pix = pixConvert2To8(pixs, 0, 85, 170, 255, 1);
420  d = 8;
421  } else {
422  pix = pixCopy(NULL, pixs);
423  }
424  fdepth = (d == 32) ? 24 : d;
425 
426  /* Resolution is given in pixels/meter */
427  xres = (l_int32)(39.37 * (l_float32)pixGetXRes(pix) + 0.5);
428  yres = (l_int32)(39.37 * (l_float32)pixGetYRes(pix) + 0.5);
429 
430  pixWpl = pixGetWpl(pix);
431  pixBpl = 4 * pixWpl;
432  fWpl = (w * fdepth + 31) / 32;
433  fBpl = 4 * fWpl;
434  fimagebytes = h * fBpl;
435  if (fimagebytes > 4LL * L_MAX_ALLOWED_PIXELS) {
436  pixDestroy(&pix);
437  return ERROR_INT("image data is too large", procName, 1);
438  }
439 
440  /* If not rgb or 16 bpp, the bmp data is required to have a colormap */
441  heapcm = 0;
442  if (d == 32 || d == 16) { /* 24 bpp rgb or 16 bpp: no colormap */
443  ncolors = 0;
444  cmaplen = 0;
445  } else if ((cmap = pixGetColormap(pix))) { /* existing colormap */
446  ncolors = pixcmapGetCount(cmap);
447  cmaplen = ncolors * sizeof(RGBA_QUAD);
448  cta = (l_uint8 *)cmap->array;
449  } else { /* no existing colormap; d <= 8; make a binary or gray one */
450  if (d == 1) {
451  cmaplen = sizeof(bwmap);
452  ncolors = 2;
453  cta = (l_uint8 *)bwmap;
454  } else { /* d = 2,4,8; use a grayscale output colormap */
455  ncolors = 1 << fdepth;
456  cmaplen = ncolors * sizeof(RGBA_QUAD);
457  heapcm = 1;
458  cta = (l_uint8 *)LEPT_CALLOC(cmaplen, 1);
459  stepsize = 255 / (ncolors - 1);
460  for (i = 0, val = 0, pquad = (RGBA_QUAD *)cta;
461  i < ncolors;
462  i++, val += stepsize, pquad++) {
463  pquad->blue = pquad->green = pquad->red = val;
464  pquad->alpha = 255; /* opaque */
465  }
466  }
467  }
468 
469 #if DEBUG
470  {l_uint8 *pcmptr;
471  pcmptr = (l_uint8 *)pixGetColormap(pix)->array;
472  fprintf(stderr, "Pix colormap[0] = %c%c%c%d\n",
473  pcmptr[0], pcmptr[1], pcmptr[2], pcmptr[3]);
474  fprintf(stderr, "Pix colormap[1] = %c%c%c%d\n",
475  pcmptr[4], pcmptr[5], pcmptr[6], pcmptr[7]);
476  }
477 #endif /* DEBUG */
478 
479  offbytes = BMP_FHBYTES + BMP_IHBYTES + cmaplen;
480  fsize = offbytes + fimagebytes;
481  fdata = (l_uint8 *)LEPT_CALLOC(fsize, 1);
482  *pfdata = fdata;
483  *pfsize = fsize;
484 
485  /* Convert to little-endian and write the file header data */
486  bmpfh = (BMP_FH *)fdata;
487  bmpfh->bfType = convertOnBigEnd16(BMP_ID);
488  bmpfh->bfSize = convertOnBigEnd16(fsize & 0x0000ffff);
489  bmpfh->bfFill1 = convertOnBigEnd16((fsize >> 16) & 0x0000ffff);
490  bmpfh->bfOffBits = convertOnBigEnd16(offbytes & 0x0000ffff);
491  bmpfh->bfFill2 = convertOnBigEnd16((offbytes >> 16) & 0x0000ffff);
492 
493  /* Convert to little-endian and write the info header data */
494  bmpih = (BMP_IH *)(fdata + BMP_FHBYTES);
495  bmpih->biSize = convertOnBigEnd32(BMP_IHBYTES);
496  bmpih->biWidth = convertOnBigEnd32(w);
497  bmpih->biHeight = convertOnBigEnd32(h);
498  bmpih->biPlanes = convertOnBigEnd16(1);
499  bmpih->biBitCount = convertOnBigEnd16(fdepth);
500  bmpih->biSizeImage = convertOnBigEnd32(fimagebytes);
501  bmpih->biXPelsPerMeter = convertOnBigEnd32(xres);
502  bmpih->biYPelsPerMeter = convertOnBigEnd32(yres);
503  bmpih->biClrUsed = convertOnBigEnd32(ncolors);
504  bmpih->biClrImportant = convertOnBigEnd32(ncolors);
505 
506  /* Copy the colormap data and free the cta if necessary */
507  if (ncolors > 0) {
508  memcpy(fdata + BMP_FHBYTES + BMP_IHBYTES, cta, cmaplen);
509  if (heapcm) LEPT_FREE(cta);
510  }
511 
512  /* When you write a binary image with a colormap
513  * that sets BLACK to 0, you must invert the data */
514  if (fdepth == 1 && cmap && ((l_uint8 *)(cmap->array))[0] == 0x0) {
515  pixInvert(pix, pix);
516  }
517 
518  /* An endian byte swap is also required */
519  pixEndianByteSwap(pix);
520 
521  /* Transfer the image data. Image origin for bmp is at lower right. */
522  fmdata = fdata + offbytes;
523  if (fdepth != 24) { /* typ 1 or 8 bpp */
524  data = (l_uint8 *)pixGetData(pix) + pixBpl * (h - 1);
525  for (i = 0; i < h; i++) {
526  memcpy(fmdata, data, fBpl);
527  data -= pixBpl;
528  fmdata += fBpl;
529  }
530  } else { /* 32 bpp pix; 24 bpp file
531  * See the comments in pixReadStreamBmp() to
532  * understand the logic behind the pixel ordering below.
533  * Note that we have again done an endian swap on
534  * little endian machines before arriving here, so that
535  * the bytes are ordered on both platforms as:
536  Red Green Blue --
537  |-----------|------------|-----------|-----------|
538  */
539  extrabytes = fBpl - 3 * w;
540  line = pixGetData(pix) + pixWpl * (h - 1);
541  for (i = 0; i < h; i++) {
542  for (j = 0; j < w; j++) {
543  pword = line + j;
544  pel[2] = *((l_uint8 *)pword + COLOR_RED);
545  pel[1] = *((l_uint8 *)pword + COLOR_GREEN);
546  pel[0] = *((l_uint8 *)pword + COLOR_BLUE);
547  memcpy(fmdata, &pel, 3);
548  fmdata += 3;
549  }
550  if (extrabytes) {
551  for (k = 0; k < extrabytes; k++) {
552  memcpy(fmdata, &pel, 1);
553  fmdata++;
554  }
555  }
556  line -= pixWpl;
557  }
558  }
559 
560  pixDestroy(&pix);
561  return 0;
562 }
563 
564 /* --------------------------------------------*/
565 #endif /* USE_BMPIO */
l_uint8 alpha
Definition: pix.h:174
PIX * pixRemoveColormap(PIX *pixs, l_int32 type)
pixRemoveColormap()
Definition: pixconv.c:322
l_int16 bfType
Definition: bmp.h:52
l_int32 pixEndianByteSwap(PIX *pixs)
pixEndianByteSwap()
Definition: pix2.c:2930
l_int16 biBitCount
Definition: bmp.h:81
l_int16 bfSize
Definition: bmp.h:53
#define BMP_FHBYTES
Definition: bmp.h:67
l_int32 n
Definition: pix.h:160
PIX * pixReadStreamBmp(FILE *fp)
pixReadStreamBmp()
Definition: bmpio.c:89
l_int32 biCompression
Definition: bmp.h:82
l_uint8 red
Definition: pix.h:173
PIX * pixReadMemBmp(const l_uint8 *cdata, size_t size)
pixReadMemBmp()
Definition: bmpio.c:119
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
Definition: pix1.c:302
PIX * pixInvert(PIX *pixd, PIX *pixs)
pixInvert()
Definition: pix3.c:1395
l_uint32 * pixGetData(PIX *pix)
pixGetData()
Definition: pix1.c:1602
l_int32 biSize
Definition: bmp.h:77
l_int32 biXPelsPerMeter
Definition: bmp.h:84
l_int16 bfFill2
Definition: bmp.h:62
l_uint8 blue
Definition: pix.h:171
PIXCMAP * pixcmapCreate(l_int32 depth)
pixcmapCreate()
Definition: colormap.c:110
l_int32 biHeight
Definition: bmp.h:79
l_int32 biClrUsed
Definition: bmp.h:86
l_int16 bfFill1
Definition: bmp.h:58
l_int32 biWidth
Definition: bmp.h:78
l_int32 pixWriteStreamBmp(FILE *fp, PIX *pix)
pixWriteStreamBmp()
Definition: bmpio.c:339
l_int32 pixSetColormap(PIX *pix, PIXCMAP *colormap)
pixSetColormap()
Definition: pix1.c:1556
#define BMP_IHBYTES
Definition: bmp.h:92
l_uint8 green
Definition: pix.h:172
Definition: pix.h:169
l_int16 bfOffBits
Definition: bmp.h:61
l_int32 pixWriteMemBmp(l_uint8 **pfdata, size_t *pfsize, PIX *pixs)
pixWriteMemBmp()
Definition: bmpio.c:384
void pixDestroy(PIX **ppix)
pixDestroy()
Definition: pix1.c:545
l_int32 biClrImportant
Definition: bmp.h:87
l_uint8 * l_binaryReadStream(FILE *fp, size_t *pnbytes)
l_binaryReadStream()
Definition: utils2.c:1200
l_int32 biYPelsPerMeter
Definition: bmp.h:85
PIX * pixConvert2To8(PIX *pixs, l_uint8 val0, l_uint8 val1, l_uint8 val2, l_uint8 val3, l_int32 cmapflag)
pixConvert2To8()
Definition: pixconv.c:2456
void * array
Definition: pix.h:157
l_int32 pixcmapGetCount(PIXCMAP *cmap)
pixcmapGetCount()
Definition: colormap.c:593
Definition: pix.h:134
PIX * pixCopy(PIX *pixd, PIX *pixs)
pixCopy()
Definition: pix1.c:630
Definition: pix.h:201
l_int32 biSizeImage
Definition: bmp.h:83
l_int32 pixGetDimensions(PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
Definition: pix1.c:1052
l_int32 pixcmapSetAlpha(PIXCMAP *cmap, l_int32 index, l_int32 aval)
pixcmapSetAlpha()
Definition: colormap.c:892
l_int16 biPlanes
Definition: bmp.h:80