readpng2.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*---------------------------------------------------------------------------
  2. rpng2 - progressive-model PNG display program readpng2.h
  3. ---------------------------------------------------------------------------
  4. Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
  5. This software is provided "as is," without warranty of any kind,
  6. express or implied. In no event shall the author or contributors
  7. be held liable for any damages arising in any way from the use of
  8. this software.
  9. The contents of this file are DUAL-LICENSED. You may modify and/or
  10. redistribute this software according to the terms of one of the
  11. following two licenses (at your option):
  12. LICENSE 1 ("BSD-like with advertising clause"):
  13. Permission is granted to anyone to use this software for any purpose,
  14. including commercial applications, and to alter it and redistribute
  15. it freely, subject to the following restrictions:
  16. 1. Redistributions of source code must retain the above copyright
  17. notice, disclaimer, and this list of conditions.
  18. 2. Redistributions in binary form must reproduce the above copyright
  19. notice, disclaimer, and this list of conditions in the documenta-
  20. tion and/or other materials provided with the distribution.
  21. 3. All advertising materials mentioning features or use of this
  22. software must display the following acknowledgment:
  23. This product includes software developed by Greg Roelofs
  24. and contributors for the book, "PNG: The Definitive Guide,"
  25. published by O'Reilly and Associates.
  26. LICENSE 2 (GNU GPL v2 or later):
  27. This program is free software; you can redistribute it and/or modify
  28. it under the terms of the GNU General Public License as published by
  29. the Free Software Foundation; either version 2 of the License, or
  30. (at your option) any later version.
  31. This program is distributed in the hope that it will be useful,
  32. but WITHOUT ANY WARRANTY; without even the implied warranty of
  33. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  34. GNU General Public License for more details.
  35. You should have received a copy of the GNU General Public License
  36. along with this program; if not, write to the Free Software Foundation,
  37. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  38. ---------------------------------------------------------------------------*/
  39. #ifndef TRUE
  40. # define TRUE 1
  41. # define FALSE 0
  42. #endif
  43. #ifndef MAX
  44. # define MAX(a,b) ((a) > (b)? (a) : (b))
  45. # define MIN(a,b) ((a) < (b)? (a) : (b))
  46. #endif
  47. #ifdef DEBUG
  48. # define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);}
  49. #else
  50. # define Trace(x) ;
  51. #endif
  52. enum rpng2_states {
  53. kPreInit = 0,
  54. kWindowInit,
  55. kDone
  56. };
  57. typedef unsigned char uch;
  58. typedef unsigned short ush;
  59. typedef unsigned long ulg;
  60. typedef struct _mainprog_info {
  61. double display_exponent;
  62. ulg width;
  63. ulg height;
  64. void *png_ptr;
  65. void *info_ptr;
  66. void (*mainprog_init)(void);
  67. void (*mainprog_display_row)(ulg row_num);
  68. void (*mainprog_finish_display)(void);
  69. uch *image_data;
  70. uch **row_pointers;
  71. jmp_buf jmpbuf;
  72. int passes; /* not used */
  73. int pass;
  74. int rowbytes;
  75. int channels;
  76. int need_bgcolor;
  77. int state;
  78. uch bg_red;
  79. uch bg_green;
  80. uch bg_blue;
  81. } mainprog_info;
  82. /* prototypes for public functions in readpng2.c */
  83. void readpng2_version_info(void);
  84. int readpng2_check_sig(uch *sig, int num);
  85. int readpng2_init(mainprog_info *mainprog_ptr);
  86. int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length);
  87. void readpng2_cleanup(mainprog_info *mainprog_ptr);