w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

png2bmp.c
Go to the documentation of this file.
1 /*
2 ** png2bmp --- conversion from PNG to (Windows style) BMP
3 **
4 ** Copyright (C) 1999-2005 MIYASAKA Masaru
5 **
6 ** For conditions of distribution and use,
7 ** see copyright notice in common.h.
8 */
9 
10 #include "common.h"
11 #include "bmphed.h"
12 
13 #if PNG_LIBPNG_VER == 10500 /* Avoid a bug https://sourceforge.net/p/libpng/bugs/165/ */
14 #include <pngpriv.h>
15 #endif
16 
17 #define PNG2BMP_VERSION "1.62 (Sep 4, 2005)"
18 #define PNG2BMP_COPYRIGHT "Copyright (C) 1999-2005 MIYASAKA Masaru"
19 
20 char outnam[FILENAME_MAX];
21 char outdir[FILENAME_MAX];
22 int deletesrc = 0;
23 int copytime = 0;
24 
25 #define P2B_ALPHABMP_NONE 0
26 #define P2B_ALPHABMP_ARGB 1 /* -a option; 32bit ARGB(RGB) BMP */
27 #define P2B_ALPHABMP_BITFIELD 2 /* -b option; 32bit Bitfield BMP */
28 
30 int expand_trans = 0;
31 
32 #if defined(WIN32) || defined(MSDOS)
33 const char errlogfile[] = ".\\P2BERROR.LOG";
34 #else
35 const char errlogfile[] = "./p2berror.log";
36 #endif
37 
38  /* error messages */
39 #ifdef JAPANESE /* ---------- */
40 const char wrn_mkdirfail[] =
41  "WARNING: 出力先ディレクトリを作れません - %s\n"
42  "WARNING: -> -%c オプション での出力先指定は無視されます\n";
43 const char err_ropenfail[] = "SKIPPED: 該当するファイルがありません - %s\n";
44 const char err_wopenfail[] = "SKIPPED: 出力ファイルを作成できません - %s\n";
45 const char err_outofmemory[] = "SKIPPED: 作業用メモリが確保できません - %s\n";
46  /* -- */
47 const char err_writeerr[] = "SKIPPED: 書き込みエラーが発生しました - %s\n";
48 const char err_not_a_png[] = "SKIPPED: PNG ファイルではありません - %s\n";
49 #else /* ------------------- */
50 const char wrn_mkdirfail[] =
51  "WARNING: Cannot create a directory - %s\n"
52  "WARNING: -> Output directory specified by '-%c' will be ignored.\n";
53 const char err_ropenfail[] = "SKIPPED: No such file or directory - %s\n";
54 const char err_wopenfail[] = "SKIPPED: Cannot create - %s\n";
55 const char err_outofmemory[] = "SKIPPED: Out of memory - %s\n";
56  /* -- */
57 const char err_writeerr[] = "SKIPPED: Write operation failed - %s\n";
58 const char err_not_a_png[] = "SKIPPED: Not a PNG file - %s\n";
59 #endif /* ------------------- */
60 
61 static BOOL read_png(char *, IMAGE *);
62 static int skip_macbinary(png_structp);
64 static BOOL write_bmp(char *, IMAGE *);
65 static const char *write_rgb_bits(IMAGE *, FILE *);
66 static void mputdwl(void *, unsigned long);
67 static void mputwl(void *, unsigned int);
68 static void usage_exit(char *, int);
69 
70 
71 
72 /*
73 ** メイン
74 */
75 int main(int argc, char *argv[])
76 {
77  char outf[FILENAME_MAX];
78  IMAGE image;
79  int opt;
80  char *arg;
81  char *p, c;
82  int r_stdin, w_stdout;
83  int failure = 0, success = 0;
84 
85 #ifdef __LCC__ /* lcc-win32 */
86  char **envp;
87  void _GetMainArgs(int *, char ***, char ***, int);
88  _GetMainArgs(&argc, &argv, &envp, 1);
89 #endif
90 #ifdef __EMX__
91  _wildcard(&argc, &argv);
92 #endif
93  envargv(&argc, &argv, "B2P");
94 
95  r_stdin = !isatty(fileno(stdin));
96  w_stdout = !isatty(fileno(stdout));
97 
98  while (parsearg(&opt, &arg, argc, argv, "DdOoFfPp")) {
99  switch (toupper(opt)) {
100  case 'E': deletesrc ^= 1; break;
101  case 'T': copytime ^= 1; break;
102  case 'Q': quietmode ^= 1; break;
103  case 'L': errorlog ^= 1; break;
104 
105  case 'X':
106  r_stdin = 0;
107  w_stdout = 0;
108  break;
109 
110  case 'A':
113  break;
114 
115  case 'B':
118  break;
119 
120  case 'R':
121  expand_trans ^= 1;
122  break;
123 
124  case 'F':
125  /* '-F' option of bmp2png (ignored on png2bmp) */
126  break;
127 
128  case 'P':
129  /* '-P' option of bmp2png (ignored on png2bmp) */
130  break;
131 
132  case 'D': /* output directory */
133  if (*arg == '-') arg = NULL;
134  if (arg == NULL) {
135  outdir[0] = '\0';
136  } else {
137  strcpy(outdir, arg);
138  addslash(outdir);
139  if (makedir(outdir) != 0) {
141  outdir[0] = '\0';
142  }
143  }
144  break;
145 
146  case 'O': /* output filename */
147  if (arg == NULL) {
148  outnam[0] = '\0';
149  } else {
150  strcpy(outnam, arg);
151  p = basname(outnam);
152  c = *p; *p = '\0';
153  if (makedir(outnam) != 0) {
155  outnam[0] = '\0';
156  } else {
157  *p = c;
158  }
159  }
160  break;
161 
162  case 0x00: /* input file spec */
163  if (outnam[0] != '\0') {
164  strcpy(outf, outnam);
165  outnam[0] = '\0';
166  } else if (w_stdout) {
167  if (!read_png(arg, &image)) return 1;
168  if (!write_bmp(NULL, &image)) return 1;
169  if (deletesrc) remove(arg);
170  return 0;
171  } else {
172  if (outdir[0] != '\0') {
173  strcat(strcpy(outf, outdir), basname(arg));
174  } else {
175  strcpy(outf, arg);
176  }
177 #ifdef WIN32_LFN
178  strcpy(suffix(outf), is_dos_filename(outf) ? ".BMP" : ".bmp");
179 #else
180  strcpy(suffix(outf), ".bmp");
181 #endif
182  }
183  /* ---------------------- */
184  if (!read_png(arg, &image)) {
185  failure++;
186  break;
187  }
188  renbak(outf);
189  if (!write_bmp(outf, &image)) {
190  failure++;
191  break;
192  }
193  /* ---------------------- */
194  if (copytime) cpyftime(arg, outf);
195  if (deletesrc) remove(arg);
196  /* ---------------------- */
197  success++;
198  break;
199 
200  default:
201  ; /* Ignore unknown option */
202  }
203  }
204  if (failure == 0 && success == 0) {
205  if (!r_stdin) usage_exit(argv[0], 255);
206  if (!read_png(NULL, &image)) return 1;
207  if (outnam[0] != '\0') {
208  renbak(outnam);
209  return !write_bmp(outnam, &image);
210  } else if (w_stdout) {
211  return !write_bmp(NULL, &image);
212  } else {
213  strcat(strcpy(outf, outdir), "___stdin.bmp");
214  renbak(outf);
215  return !write_bmp(outf, &image);
216  }
217  }
218 
219  return (failure > 255) ? 255 : failure;
220 }
221 
222 
223 /* -----------------------------------------------------------------------
224 ** PNG ファイルの読み込み
225 */
226 
227 #define ERROR_ABORT(s) do { errmsg = (s); goto error_abort; } while (0)
228 
229 /*
230 ** .pngファイルからの読み込み
231 */
232 static BOOL read_png(char *fn, IMAGE *img)
233 {
235  png_infop info_ptr, end_info;
237  int bit_depth, color_type;
238  int xbit_depth, xcolor_type, xchannels;
239  const char *errmsg;
240  FILE *fp;
241 
242  imgbuf_init(img);
243 
244  if (fn == NULL) {
245  fn = " (stdin)";
246  fp = binary_stdio(fileno(stdin));
247  } else {
248  fp = fopen(fn, "rb");
249  }
250  if (fp == NULL) ERROR_ABORT(err_ropenfail);
251 
252  set_status("Reading %.80s", basname(fn));
253 
254  /* ------------------------------------------------------ */
255 
258  if (png_ptr == NULL) {
260  }
261  info_ptr = png_create_info_struct(png_ptr);
262  end_info = png_create_info_struct(png_ptr);
263  if (info_ptr == NULL || end_info == NULL) {
264  png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
266  }
267  if (setjmp(png_jmpbuf(png_ptr))) {
268  /* If we get here, we had a problem writing the file */
269  png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
270  ERROR_ABORT(NULL);
271  }
274 
275  /* ------------------------------------------------------ */
276 
277  png_read_info(png_ptr, info_ptr);
278 
279  png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth,
280  &color_type, NULL, NULL, NULL);
281 
282  /* ------------------------------------------------------ */
283 
284  if (color_type & PNG_COLOR_MASK_ALPHA) {
287  color_type &= ~~PNG_COLOR_MASK_ALPHA;
288  }
289  } else if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
292  color_type |= PNG_COLOR_MASK_ALPHA;
293  color_type &= ~~PNG_COLOR_MASK_PALETTE;
294  }
295  }
296  if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
298  }
299  if (color_type == PNG_COLOR_TYPE_RGB ||
300  color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
302  }
303  if (!(color_type & PNG_COLOR_MASK_ALPHA) && bit_depth == 2) {
306  }
307  if (bit_depth == 16)
309 
310  png_read_update_info(png_ptr, info_ptr);
311 
312  /* ------------------------------------------------------ */
313 
314  png_get_IHDR(png_ptr, info_ptr, &width, &height, &xbit_depth,
315  &xcolor_type, NULL, NULL, NULL);
316  xchannels = png_get_channels(png_ptr, info_ptr);
317 
318  img->width = (LONG)width;
319  img->height = (LONG)height;
320  img->pixdepth = (UINT)xbit_depth * xchannels;
321  img->palnum = (img->pixdepth <= 8) ? (1 << img->pixdepth) : 0;
322  img->topdown = FALSE;
323  img->alpha = (xcolor_type & PNG_COLOR_MASK_ALPHA) ? TRUE : FALSE;
324 
325  if (!imgbuf_alloc(img)) {
326  png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
328  }
329 
330  if (img->palnum > 0) {
331  if (xcolor_type == PNG_COLOR_TYPE_PALETTE) {
332  png_colorp palette;
333  int num_palette;
334  png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
335  if (num_palette > (int)img->palnum) num_palette = img->palnum;
336  memset(img->palette, 0, img->palnum * sizeof(png_color));
337  memcpy(img->palette, palette, num_palette * sizeof(png_color));
338  } else {
339  int depth = (bit_depth == 16) ? 8 : bit_depth;
340  memset(img->palette, 0, img->palnum * sizeof(png_color));
342  }
343  }
344 
345  /* ------------------------------------------------------ */
346 
349 #if PNG_LIBPNG_VER == 10500 /* Avoid a bug https://sourceforge.net/p/libpng/bugs/165/ */
350  png_ptr->transformations |= PNG_INTERLACE;
351 #endif
353 
354  png_read_end(png_ptr, end_info);
355  png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
356 
357  /* ------------------------------------------------------ */
358 
359  set_status("Read OK %.80s", basname(fn));
360 
361  if (fp != stdin) fclose(fp);
362 
363  return TRUE;
364 
365 error_abort: /* error */
366  if (errmsg != NULL) xxprintf(errmsg, fn);
367  if (fp != stdin && fp != NULL) fclose(fp);
368  imgbuf_free(img);
369 
370  return FALSE;
371 }
372 
373 
374 /*
375 ** ファイル先頭にあるマックバイナリを読み跳ばす
376 */
378 {
380  enum { PNG_BYTES_TO_CHECK = 8, MACBIN_SIZE = 128 }; /* ^ in pngrio.c */
381  png_byte buf[MACBIN_SIZE];
382  png_bytep sig;
383 
384  png_read_data(png_ptr, buf, PNG_BYTES_TO_CHECK);
385  if (png_sig_cmp(buf, 0, PNG_BYTES_TO_CHECK) == 0)
386  return PNG_BYTES_TO_CHECK;
387 
388  png_read_data(png_ptr, buf, MACBIN_SIZE);
389  sig = buf + MACBIN_SIZE - PNG_BYTES_TO_CHECK;
390  if (png_sig_cmp(sig, 0, PNG_BYTES_TO_CHECK) == 0)
391  return PNG_BYTES_TO_CHECK;
392 
394  longjmp(png_jmpbuf(png_ptr), 1);
395 
396  return 0; /* to quiet compiler warnings */
397 }
398 
399 
400 /*
401 ** 4色形式 -> 16色形式への変換
402 */
404 {
405  static const png_byte pix[] = {
406  0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
407  0x20, 0x21, 0x22, 0x23, 0x30, 0x31, 0x32, 0x33,
408  };
409  png_uint_32 rowb;
410  png_bytep p, q;
411  png_byte c;
412 
413  rowb = (row_info->width + 1) / 2;
414  q = data + rowb;
415  p = data + rowb / 2;
416 
417  if (rowb % 2 == 1) {
418  c = *p;
419  *(--q) = pix[c >> 4];
420  }
421  while (p > data) {
422  c = *(--p);
423  *(--q) = pix[c & 0x0F];
424  *(--q) = pix[c >> 4];
425  }
426  row_info->bit_depth = 4;
427  row_info->pixel_depth = 4;
428  row_info->rowbytes = rowb;
429 }
430 
431 
432 /* -----------------------------------------------------------------------
433 ** BMP ファイルの書き込み
434 */
435 
436 /*
437 ** .bmp ファイルの書き込み
438 */
439 static BOOL write_bmp(char *fn, IMAGE *img)
440 {
442  BYTE *const bih = bfh + FILEHED_SIZE;
443  BYTE rgbq[RGBQUAD_SIZE];
444  BOOL alpha_bitfield;
445  DWORD bihsize, offbits, filesize;
446  PALETTE *pal;
447  const char *errmsg;
448  FILE *fp;
449  UINT i;
450 
451  if (fn == NULL) {
452  fn = " (stdout)";
454  } else {
455  fp = fopen(fn, "wb");
456  }
457  if (fp == NULL) ERROR_ABORT(err_wopenfail);
458 
459  set_status("Writing %.80s", basname(fn));
460 
461  /* ------------------------------------------------------ */
462 
463  alpha_bitfield = (img->alpha && alpha_format == P2B_ALPHABMP_BITFIELD);
464  bihsize = (alpha_bitfield) ? BMPV4HED_SIZE : INFOHED_SIZE;
465  offbits = FILEHED_SIZE + bihsize + RGBQUAD_SIZE * img->palnum;
466  filesize = offbits + img->imgbytes;
467 
468  memset(bfh, 0, sizeof(bfh));
469 
470  mputwl( bfh + BFH_WTYPE , BMP_SIGNATURE);
471  mputdwl(bfh + BFH_DSIZE , filesize);
472  mputdwl(bfh + BFH_DOFFBITS, offbits);
473 
474  mputdwl(bih + BIH_DSIZE , bihsize);
475  mputdwl(bih + BIH_LWIDTH , (DWORD)img->width);
476  mputdwl(bih + BIH_LHEIGHT , (DWORD)img->height);
477  mputwl( bih + BIH_WPLANES , 1);
478  mputwl( bih + BIH_WBITCOUNT , img->pixdepth);
479  mputdwl(bih + BIH_DSIZEIMAGE, img->imgbytes);
480 
481  if (alpha_bitfield) {
483  mputdwl(bih + B4H_DALPHAMASK, 0xFF000000);
484  mputdwl(bih + B4H_DREDMASK , 0x00FF0000);
485  mputdwl(bih + B4H_DGREENMASK, 0x0000FF00);
486  mputdwl(bih + B4H_DBLUEMASK , 0x000000FF);
487  }
488 
489  if (fwrite(bfh, (FILEHED_SIZE + bihsize), 1, fp) != 1)
491 
492  /* ------------------------------------------------------ */
493 
494  memset(rgbq, 0, sizeof(rgbq));
495 
496  for (pal = img->palette, i = img->palnum; i > 0; i--, pal++) {
497  rgbq[RGBQ_RED] = pal->red;
498  rgbq[RGBQ_GREEN] = pal->green;
499  rgbq[RGBQ_BLUE] = pal->blue;
500  if (fwrite(rgbq, RGBQUAD_SIZE, 1, fp) != 1)
502  }
503 
504  /* ------------------------------------------------------ */
505 
506  if ((errmsg = write_rgb_bits(img, fp)) != NULL) ERROR_ABORT(errmsg);
507 
508  /* ------------------------------------------------------ */
509 
510  set_status("OK %.80s", basname(fn));
511  feed_line();
512 
513  fflush(fp);
514  if (fp != stdout) fclose(fp);
515  imgbuf_free(img);
516 
517  return TRUE;
518 
519 error_abort: /* error */
520  xxprintf(errmsg, fn);
521  if (fp != stdout && fp != NULL) fclose(fp);
522  imgbuf_free(img);
523 
524  return FALSE;
525 }
526 
527 
528 /*
529 ** BI_RGB (無圧縮) 形式の画像データを書く
530 */
531 static const char *write_rgb_bits(IMAGE *img, FILE *fp)
532 {
533 #if 1
534  DWORD wr = 16*1024*1024;
535  DWORD num = img->imgbytes;
536  BYTE *ptr = img->bmpbits;
537 
538  while (num > 0) {
539  if (wr > num) wr = num;
540 
541  if (fwrite(ptr, wr, 1, fp) != 1)
542  return err_writeerr;
543 
544  ptr += wr; num -= wr;
545  }
546 #else
547  if (fwrite(img->bmpbits, img->imgbytes, 1, fp) != 1)
548  return err_writeerr;
549 #endif
550  return NULL;
551 }
552 
553 
554 /*
555 ** メモリへ little-endien 形式 4バイト無符号整数を書く
556 */
557 static void mputdwl(void *ptr, unsigned long val)
558 {
559  unsigned char *p = ptr;
560 
561  p[0] = (unsigned char)(val & 0xFF);
562  p[1] = (unsigned char)(val >> 8 & 0xFF);
563  p[2] = (unsigned char)(val >> 16 & 0xFF);
564  p[3] = (unsigned char)(val >> 24 & 0xFF);
565 }
566 
567 
568 /*
569 ** メモリへ little-endien 形式 2バイト無符号整数を書く
570 */
571 static void mputwl(void *ptr, unsigned int val)
572 {
573  unsigned char *p = ptr;
574 
575  p[0] = (unsigned char)(val & 0xFF);
576  p[1] = (unsigned char)(val >> 8 & 0xFF);
577 }
578 
579 
580 /* -----------------------------------------------------------------------
581 ** ヘルプスクリーンの表示
582 */
583 
584 /*
585 ** 使用法表示
586 */
587 static void usage_exit(char *argv0, int status)
588 {
589  static const char str_usage[] =
590 #ifdef JAPANESE /* -------------------------- */
591 #ifdef SJIS_ESCAPE
592 #define SJ_ESC(esc,raw) esc
593 #else
594 #define SJ_ESC(esc,raw) raw
595 #endif
596  "png2bmp, PNG -> BMP コンバータ - version " PNG2BMP_VERSION "\n"
597  " " PNG2BMP_COPYRIGHT "\n"
598  " Compiled with libpng " PNG_LIBPNG_VER_STRING " and zlib " ZLIB_VERSION ".\n"
599  "\n"
600  "使い方 : %s [-スイッチ] 入力ファイル名 ...\n"
601  " : ... | %s [-スイッチ] | ...\n"
602  "\n"
603  "入力ファイル名にはワイルドカードが使えます (* と ?)\n"
604  "出力ファイル名は入力ファイル名の拡張子を .bmp に変えた名前になります\n"
605  "\n"
606  "スイッチオプション (小文字でも可) :\n"
607  " -A アルファチャネルを保存する (32bit ARGB BMP 形式で)\n"
608  " -B アルファチャネルを保存する (32bit Bitfield BMP 形式で)\n"
609  " -R 透明色をアルファチャネルに変換する (-A か -B と共に使う)\n"
610  " -O name 出力ファイル名を指定する\n"
611  " -D dir ファイルを出力するディレクトリを指定する\n"
612  " -E 変換が成功した場合には入力ファイルを削除する\n"
613  " -T 入力ファイルのタイムスタンプを出力ファイルに設定する\n"
614  " -Q 処理中, 一切の" SJ_ESC("表\示","表示") "をしない\n"
615  " -L 処理中のエラーをログファイル(%s)に記録する\n"
616  " -X 標準入力/標準出力を介した変換を無効にする\n";
617 #else /* ----------------------------------- */
618  "png2bmp, a PNG-to-BMP converter - version " PNG2BMP_VERSION "\n"
619  " " PNG2BMP_COPYRIGHT "\n"
620  " Compiled with libpng " PNG_LIBPNG_VER_STRING " and zlib " ZLIB_VERSION ".\n"
621  "\n"
622  "Usage: %s [-switches] inputfile(s) ...\n"
623  " or: ... | %s [-switches] | ...\n"
624  "\n"
625  "List of input files may use wildcards (* and ?)\n"
626  "Output filename is same as input filename, but extension .bmp\n"
627  "\n"
628  "Switches (case-insensitive) :\n"
629  " -A Preserve alpha channel (save in 32bit ARGB BMP format)\n"
630  " -B Preserve alpha channel (save in 32bit Bitfield BMP format)\n"
631  " -R Convert transparent color to alpha channel (use with -A or -B)\n"
632  " -O name Specify name for output file\n"
633  " -D dir Output files into dir\n"
634  " -E Delete input files after successful conversion\n"
635  " -T Set the timestamp of input file on output file\n"
636  " -Q Quiet mode\n"
637  " -L Log errors to %s file\n"
638  " -X Disable conversion through standard input/output\n";
639 #endif /* ----------------------------------- */
640 #if defined(WIN32) || defined(MSDOS)
641  char exename[FILENAME_MAX];
642  char *p;
643 
644  argv0 = strcpy(exename, basname(argv0));
645  for (p = argv0; *p != '\0'; p++) *p = tolower(*p);
646 #endif
647  fprintf(stdout, str_usage, argv0, argv0, errlogfile);
648 
649  exit(status);
650 }
651 
q
Definition: afm2pl.c:2287
#define width(a)
Definition: aptex-macros.h:198
#define depth(a)
Definition: aptex-macros.h:199
#define height(a)
Definition: aptex-macros.h:200
#define BI_BITFIELDS
Definition: bmphed.h:79
#define BIH_WBITCOUNT
Definition: bmphed.h:29
#define RGBQUAD_SIZE
Definition: bmphed.h:66
#define RGBQ_RED
Definition: bmphed.h:64
#define BFH_DOFFBITS
Definition: bmphed.h:19
#define BFH_WTYPE
Definition: bmphed.h:15
#define B4H_DBLUEMASK
Definition: bmphed.h:38
#define FILEHED_SIZE
Definition: bmphed.h:21
#define BMP_SIGNATURE
Definition: bmphed.h:11
#define BFH_DSIZE
Definition: bmphed.h:16
#define BIH_LWIDTH
Definition: bmphed.h:26
#define RGBQ_BLUE
Definition: bmphed.h:62
#define BIH_LHEIGHT
Definition: bmphed.h:27
#define B4H_DREDMASK
Definition: bmphed.h:36
#define BIH_WPLANES
Definition: bmphed.h:28
#define BIH_DSIZE
Definition: bmphed.h:25
#define RGBQ_GREEN
Definition: bmphed.h:63
#define BIH_DCOMPRESSION
Definition: bmphed.h:30
#define B4H_DGREENMASK
Definition: bmphed.h:37
#define INFOHED_SIZE
Definition: bmphed.h:49
#define B4H_DALPHAMASK
Definition: bmphed.h:39
#define BMPV4HED_SIZE
Definition: bmphed.h:50
#define BIH_DSIZEIMAGE
Definition: bmphed.h:31
BOOL
Definition: dd.h:100
@ FALSE
Definition: dd.h:101
@ TRUE
Definition: dd.h:102
#define fopen
Definition: xxstdio.h:21
#define fflush
Definition: xxstdio.h:24
char * strcpy()
FILE * outf
Definition: dvibook.c:99
struct rect data
Definition: dvipdfm.c:64
#define c(n)
Definition: gpos-common.c:150
#define memcpy(d, s, n)
Definition: gsftopk.c:64
pinfo pal
Definition: in_pcx.cpp:145
pix
Definition: in_pcx.cpp:383
unsigned char * image
Definition: in_pcx.cpp:323
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p
Definition: afcover.h:72
small capitals from c petite p scientific i
Definition: afcover.h:80
#define ZLIB_VERSION
Definition: zlib.h:40
void exit()
static const char argv0[]
Definition: webpng.c:25
int png_sig_cmp(png_const_bytep sig, size_t start, size_t num_to_check)
Definition: png.c:74
void png_set_sig_bytes(png_structrp png_ptr, int num_bytes)
Definition: png.c:47
void png_init_io(png_structrp png_ptr, png_FILE_p fp)
Definition: png.c:703
void png_build_grayscale_palette(int bit_depth, png_colorp palette)
Definition: png.c:875
png_infop png_create_info_struct(png_const_structrp png_ptr)
Definition: png.c:354
png_structp() png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)
Definition: pngread.c:27
void() png_set_strip_16(png_structrp png_ptr)
Definition: pngrtran.c:197
png_byte() png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:467
#define PNG_COLOR_TYPE_RGB
Definition: png.h:670
void() png_read_update_info(png_structrp png_ptr, png_inforp info_ptr)
Definition: pngread.c:267
void() png_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn)
Definition: pngread.c:1037
#define png_jmpbuf(png_ptr)
Definition: png.h:952
png_uint_32() png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr, png_colorp *palette, int *num_palette)
Definition: pngget.c:1012
void() png_set_read_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr read_user_transform_fn)
Definition: pngrtran.c:1073
#define PNG_COLOR_TYPE_RGB_ALPHA
Definition: png.h:671
png_uint_32() png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method)
Definition: pngget.c:825
png_uint_32() png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 flag)
Definition: pngget.c:20
void() png_set_strip_alpha(png_structrp png_ptr)
Definition: pngrtran.c:210
#define PNG_COLOR_TYPE_GRAY_ALPHA
Definition: png.h:672
void() png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)
Definition: pngread.c:1011
void() png_set_gray_to_rgb(png_structrp png_ptr)
Definition: pngrtran.c:955
void() png_set_user_transform_info(png_structrp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels)
Definition: pngtrans.c:802
void() png_read_end(png_structrp png_ptr, png_inforp info_ptr)
Definition: pngread.c:766
#define PNG_COLOR_MASK_ALPHA
Definition: png.h:665
void() png_read_image(png_structrp png_ptr, png_bytepp image)
Definition: pngread.c:700
#define PNG_INFO_tRNS
Definition: png.h:736
void() png_set_bgr(png_structrp png_ptr)
Definition: pngtrans.c:21
#define PNG_COLOR_TYPE_PALETTE
Definition: png.h:669
#define PNG_LIBPNG_VER_STRING
Definition: png.h:281
void() png_read_info(png_structrp png_ptr, png_inforp info_ptr)
Definition: pngread.c:92
void() png_set_tRNS_to_alpha(png_structrp png_ptr)
Definition: pngrtran.c:926
png_voidp() png_get_error_ptr(png_const_structrp png_ptr)
Definition: pngerror.c:856
unsigned int png_uint_32
Definition: pngconf.h:511
unsigned char png_byte
Definition: pngconf.h:481
png_byte * png_bytep
Definition: pngconf.h:579
size_t png_size_t
Definition: pngconf.h:523
void png_read_data(png_structrp png_ptr, png_bytep data, size_t length)
Definition: pngrio.c:32
int num
Definition: disdvi.c:621
#define buf
unsigned char BYTE
Definition: sfnt.h:34
#define LONG
Definition: sfnt.h:31
#define fclose
Definition: debug.h:100
#define fileno
Definition: win32lib.h:72
#define isatty
Definition: win32lib.h:80
#define fprintf
Definition: mendex.h:64
Code related to b fwrite(a, sizeof(char), b, stdout) @d C_printf(c
#define png_ptr(N)
Definition: image.h:99
int remove()
void xxprintf(char *fmt,...)
Definition: common.c:103
void feed_line(void)
Definition: common.c:135
char * addslash(char *path)
Definition: common.c:649
void row_callback(png_structp png_ptr, png_uint_32 row, int pass)
Definition: common.c:234
int renbak(char *path)
Definition: common.c:544
void imgbuf_free(IMAGE *img)
Definition: common.c:330
BOOL imgbuf_alloc(IMAGE *img)
Definition: common.c:283
char * basname(char *path)
Definition: common.c:633
char ** envargv(int *argcp, char ***argvp, char *envn)
Definition: common.c:404
void set_status(char *fmt,...)
Definition: common.c:122
void init_progress_meter(png_structp png_ptr, png_uint_32 width, png_uint_32 height)
Definition: common.c:211
int errorlog
Definition: common.c:44
void imgbuf_init(IMAGE *img)
Definition: common.c:341
int makedir(char *path)
Definition: common.c:516
void png_my_warning(png_structp png_ptr, png_const_charp message)
Definition: common.c:269
void png_my_error(png_structp png_ptr, png_const_charp message)
Definition: common.c:258
int quietmode
Definition: common.c:43
FILE * binary_stdio(int fd)
Definition: common.c:590
int parsearg(int *opt, char **arg, int argc, char **argv, char *aopts)
Definition: common.c:358
int cpyftime(char *srcf, char *dstf)
Definition: common.c:573
unsigned int UINT
Definition: common.h:145
unsigned int DWORD
Definition: mktexlib.h:49
string fn
Definition: fc-lang.py:335
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF ptr
#define fp
const char * suffix
Definition: pkg_icu.cpp:27
subroutine errmsg(lineq, iccount, ibarno, msgq)
Definition: pmx294.for:7804
#define P2B_ALPHABMP_ARGB
Definition: png2bmp.c:26
static char * write_rgb_bits(IMAGE *, FILE *)
Definition: png2bmp.c:531
int expand_trans
Definition: png2bmp.c:30
int main(int argc, char *argv[])
Definition: png2bmp.c:75
#define P2B_ALPHABMP_NONE
Definition: png2bmp.c:25
static BOOL write_bmp(char *, IMAGE *)
Definition: png2bmp.c:439
char outdir[FILENAME_MAX]
Definition: png2bmp.c:21
char err_outofmemory[]
Definition: png2bmp.c:55
char err_wopenfail[]
Definition: png2bmp.c:54
int alpha_format
Definition: png2bmp.c:29
static void mputdwl(void *, unsigned long)
Definition: png2bmp.c:557
char err_ropenfail[]
Definition: png2bmp.c:53
#define PNG2BMP_VERSION
Definition: png2bmp.c:17
static int skip_macbinary(png_structp)
Definition: png2bmp.c:377
char outnam[FILENAME_MAX]
Definition: png2bmp.c:20
char err_writeerr[]
Definition: png2bmp.c:57
#define PNG2BMP_COPYRIGHT
Definition: png2bmp.c:18
char err_not_a_png[]
Definition: png2bmp.c:58
#define P2B_ALPHABMP_BITFIELD
Definition: png2bmp.c:27
static void to4bpp(png_structp, png_row_infop, png_bytep)
Definition: png2bmp.c:403
char errlogfile[]
Definition: png2bmp.c:35
static void mputwl(void *, unsigned int)
Definition: png2bmp.c:571
int deletesrc
Definition: png2bmp.c:22
static BOOL read_png(char *, IMAGE *)
Definition: png2bmp.c:232
static void usage_exit(char *, int)
Definition: png2bmp.c:587
#define ERROR_ABORT(s)
Definition: png2bmp.c:227
int copytime
Definition: png2bmp.c:23
char wrn_mkdirfail[]
Definition: png2bmp.c:50
#define PNG_INTERLACE
Definition: pngeps.c:51
type_C toupper(type_C)
bstring c int memset(void *s, int c, int length)
#define status
#define tolower(ch)
Definition: utype.h:137
Definition: sd.h:76
png_uint_32 width
Definition: png.h:756
png_byte bit_depth
Definition: png.h:759
png_byte pixel_depth
Definition: png.h:761
size_t rowbytes
Definition: png.h:757
PALETTE * palette
Definition: common.h:161
BYTE ** rowptr
Definition: common.h:162
BYTE * bmpbits
Definition: common.h:163
UINT palnum
Definition: common.h:155
UINT pixdepth
Definition: common.h:154
BOOL alpha
Definition: common.h:157
LONG height
Definition: common.h:153
BOOL topdown
Definition: common.h:156
LONG width
Definition: common.h:152
DWORD imgbytes
Definition: common.h:160
Definition: strexpr.c:21
#define FILE
Definition: t1stdio.h:34
#define argv
Definition: xmain.c:270
#define argc
Definition: xmain.c:269