| 1 |
/*--------------------------------------------------------------------------- |
| 2 |
|
| 3 |
wpng - simple PNG-writing program writepng.h |
| 4 |
|
| 5 |
--------------------------------------------------------------------------- |
| 6 |
|
| 7 |
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. |
| 8 |
|
| 9 |
This software is provided "as is," without warranty of any kind, |
| 10 |
express or implied. In no event shall the author or contributors |
| 11 |
be held liable for any damages arising in any way from the use of |
| 12 |
this software. |
| 13 |
|
| 14 |
Permission is granted to anyone to use this software for any purpose, |
| 15 |
including commercial applications, and to alter it and redistribute |
| 16 |
it freely, subject to the following restrictions: |
| 17 |
|
| 18 |
1. Redistributions of source code must retain the above copyright |
| 19 |
notice, disclaimer, and this list of conditions. |
| 20 |
2. Redistributions in binary form must reproduce the above copyright |
| 21 |
notice, disclaimer, and this list of conditions in the documenta- |
| 22 |
tion and/or other materials provided with the distribution. |
| 23 |
3. All advertising materials mentioning features or use of this |
| 24 |
software must display the following acknowledgment: |
| 25 |
|
| 26 |
This product includes software developed by Greg Roelofs |
| 27 |
and contributors for the book, "PNG: The Definitive Guide," |
| 28 |
published by O'Reilly and Associates. |
| 29 |
|
| 30 |
---------------------------------------------------------------------------*/ |
| 31 |
|
| 32 |
#ifndef TRUE |
| 33 |
# define TRUE 1 |
| 34 |
# define FALSE 0 |
| 35 |
#endif |
| 36 |
|
| 37 |
#ifndef MAX |
| 38 |
# define MAX(a,b) ((a) > (b)? (a) : (b)) |
| 39 |
# define MIN(a,b) ((a) < (b)? (a) : (b)) |
| 40 |
#endif |
| 41 |
|
| 42 |
#ifdef DEBUG |
| 43 |
# define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} |
| 44 |
#else |
| 45 |
# define Trace(x) ; |
| 46 |
#endif |
| 47 |
|
| 48 |
#define TEXT_TITLE 0x01 |
| 49 |
#define TEXT_AUTHOR 0x02 |
| 50 |
#define TEXT_DESC 0x04 |
| 51 |
#define TEXT_COPY 0x08 |
| 52 |
#define TEXT_EMAIL 0x10 |
| 53 |
#define TEXT_URL 0x20 |
| 54 |
|
| 55 |
#define TEXT_TITLE_OFFSET 0 |
| 56 |
#define TEXT_AUTHOR_OFFSET 72 |
| 57 |
#define TEXT_COPY_OFFSET (2*72) |
| 58 |
#define TEXT_EMAIL_OFFSET (3*72) |
| 59 |
#define TEXT_URL_OFFSET (4*72) |
| 60 |
#define TEXT_DESC_OFFSET (5*72) |
| 61 |
|
| 62 |
typedef unsigned char uch; |
| 63 |
typedef unsigned short ush; |
| 64 |
typedef unsigned long ulg; |
| 65 |
|
| 66 |
typedef struct _mainprog_info { |
| 67 |
double gamma; |
| 68 |
long width; |
| 69 |
long height; |
| 70 |
time_t modtime; |
| 71 |
FILE *infile; |
| 72 |
FILE *outfile; |
| 73 |
void *png_ptr; |
| 74 |
void *info_ptr; |
| 75 |
uch *image_data; |
| 76 |
uch **row_pointers; |
| 77 |
char *title; |
| 78 |
char *author; |
| 79 |
char *desc; |
| 80 |
char *copyright; |
| 81 |
char *email; |
| 82 |
char *url; |
| 83 |
int filter; /* command-line-filter flag, not PNG row filter! */ |
| 84 |
int pnmtype; |
| 85 |
int sample_depth; |
| 86 |
int interlaced; |
| 87 |
int have_bg; |
| 88 |
int have_time; |
| 89 |
int have_text; |
| 90 |
jmp_buf jmpbuf; |
| 91 |
uch bg_red; |
| 92 |
uch bg_green; |
| 93 |
uch bg_blue; |
| 94 |
} mainprog_info; |
| 95 |
|
| 96 |
|
| 97 |
/* prototypes for public functions in writepng.c */ |
| 98 |
|
| 99 |
void writepng_version_info(void); |
| 100 |
|
| 101 |
int writepng_init(mainprog_info *mainprog_ptr); |
| 102 |
|
| 103 |
int writepng_encode_image(mainprog_info *mainprog_ptr); |
| 104 |
|
| 105 |
int writepng_encode_row(mainprog_info *mainprog_ptr); |
| 106 |
|
| 107 |
int writepng_encode_finish(mainprog_info *mainprog_ptr); |
| 108 |
|
| 109 |
void writepng_cleanup(mainprog_info *mainprog_ptr); |