Visualization Library 2.0.0-b5

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
writepng.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------
2 
3  wpng - simple PNG-writing program writepng.h
4 
5  ---------------------------------------------------------------------------
6 
7  Copyright (c) 1998-2007 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  The contents of this file are DUAL-LICENSED. You may modify and/or
15  redistribute this software according to the terms of one of the
16  following two licenses (at your option):
17 
18 
19  LICENSE 1 ("BSD-like with advertising clause"):
20 
21  Permission is granted to anyone to use this software for any purpose,
22  including commercial applications, and to alter it and redistribute
23  it freely, subject to the following restrictions:
24 
25  1. Redistributions of source code must retain the above copyright
26  notice, disclaimer, and this list of conditions.
27  2. Redistributions in binary form must reproduce the above copyright
28  notice, disclaimer, and this list of conditions in the documenta-
29  tion and/or other materials provided with the distribution.
30  3. All advertising materials mentioning features or use of this
31  software must display the following acknowledgment:
32 
33  This product includes software developed by Greg Roelofs
34  and contributors for the book, "PNG: The Definitive Guide,"
35  published by O'Reilly and Associates.
36 
37 
38  LICENSE 2 (GNU GPL v2 or later):
39 
40  This program is free software; you can redistribute it and/or modify
41  it under the terms of the GNU General Public License as published by
42  the Free Software Foundation; either version 2 of the License, or
43  (at your option) any later version.
44 
45  This program is distributed in the hope that it will be useful,
46  but WITHOUT ANY WARRANTY; without even the implied warranty of
47  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48  GNU General Public License for more details.
49 
50  You should have received a copy of the GNU General Public License
51  along with this program; if not, write to the Free Software Foundation,
52  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
53 
54  ---------------------------------------------------------------------------*/
55 
56 #ifndef TRUE
57 # define TRUE 1
58 # define FALSE 0
59 #endif
60 
61 #ifndef MAX
62 # define MAX(a,b) ((a) > (b)? (a) : (b))
63 # define MIN(a,b) ((a) < (b)? (a) : (b))
64 #endif
65 
66 #ifdef DEBUG
67 # define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);}
68 #else
69 # define Trace(x) ;
70 #endif
71 
72 #define TEXT_TITLE 0x01
73 #define TEXT_AUTHOR 0x02
74 #define TEXT_DESC 0x04
75 #define TEXT_COPY 0x08
76 #define TEXT_EMAIL 0x10
77 #define TEXT_URL 0x20
78 
79 #define TEXT_TITLE_OFFSET 0
80 #define TEXT_AUTHOR_OFFSET 72
81 #define TEXT_COPY_OFFSET (2*72)
82 #define TEXT_EMAIL_OFFSET (3*72)
83 #define TEXT_URL_OFFSET (4*72)
84 #define TEXT_DESC_OFFSET (5*72)
85 
86 typedef unsigned char uch;
87 typedef unsigned short ush;
88 typedef unsigned long ulg;
89 
90 typedef struct _mainprog_info {
91  double gamma;
92  long width;
93  long height;
94  time_t modtime;
95  FILE *infile;
96  FILE *outfile;
97  void *png_ptr;
98  void *info_ptr;
99  uch *image_data;
100  uch **row_pointers;
101  char *title;
102  char *author;
103  char *desc;
104  char *copyright;
105  char *email;
106  char *url;
107  int filter; /* command-line-filter flag, not PNG row filter! */
108  int pnmtype;
111  int have_bg;
114  jmp_buf jmpbuf;
115  uch bg_red;
116  uch bg_green;
117  uch bg_blue;
118 } mainprog_info;
119 
120 
121 /* prototypes for public functions in writepng.c */
122 
123 void writepng_version_info(void);
124 
125 int writepng_init(mainprog_info *mainprog_ptr);
126 
127 int writepng_encode_image(mainprog_info *mainprog_ptr);
128 
129 int writepng_encode_row(mainprog_info *mainprog_ptr);
130 
131 int writepng_encode_finish(mainprog_info *mainprog_ptr);
132 
133 void writepng_cleanup(mainprog_info *mainprog_ptr);
char * email
Definition: writepng.h:105
char * url
Definition: writepng.h:106
struct _mainprog_info mainprog_info
FILE * outfile
Definition: writepng.h:96
unsigned short ush
Definition: writepng.h:87
char * author
Definition: writepng.h:102
void writepng_version_info(void)
Definition: writepng.c:69
void writepng_cleanup(mainprog_info *mainprog_ptr)
Definition: writepng.c:354
int sample_depth
Definition: writepng.h:109
double gamma
Definition: writepng.h:91
unsigned char uch
Definition: writepng.h:86
int writepng_init(mainprog_info *mainprog_ptr)
Definition: writepng.c:83
void * png_ptr
Definition: readpng2.h:86
char * title
Definition: writepng.h:101
FILE * infile
Definition: writepng.h:95
int writepng_encode_row(mainprog_info *mainprog_ptr)
Definition: writepng.c:295
uch * image_data
Definition: readpng2.h:91
char * desc
Definition: writepng.h:103
time_t modtime
Definition: writepng.h:94
void * info_ptr
Definition: readpng2.h:87
uch ** row_pointers
Definition: readpng2.h:92
jmp_buf jmpbuf
Definition: readpng2.h:93
int writepng_encode_image(mainprog_info *mainprog_ptr)
Definition: writepng.c:257
unsigned char uch
Definition: zutil.h:34
char * copyright
Definition: writepng.h:104
unsigned long ulg
Definition: writepng.h:88
int writepng_encode_finish(mainprog_info *mainprog_ptr)
Definition: writepng.c:325