fukasawa e60969
/*---------------------------------------------------------------------------
fukasawa e60969
fukasawa e60969
   wpng - simple PNG-writing program                             writepng.h
fukasawa e60969
fukasawa e60969
  ---------------------------------------------------------------------------
fukasawa e60969
fukasawa e60969
      Copyright (c) 1998-2007 Greg Roelofs.  All rights reserved.
fukasawa e60969
fukasawa e60969
      This software is provided "as is," without warranty of any kind,
fukasawa e60969
      express or implied.  In no event shall the author or contributors
fukasawa e60969
      be held liable for any damages arising in any way from the use of
fukasawa e60969
      this software.
fukasawa e60969
fukasawa e60969
      The contents of this file are DUAL-LICENSED.  You may modify and/or
fukasawa e60969
      redistribute this software according to the terms of one of the
fukasawa e60969
      following two licenses (at your option):
fukasawa e60969
fukasawa e60969
fukasawa e60969
      LICENSE 1 ("BSD-like with advertising clause"):
fukasawa e60969
fukasawa e60969
      Permission is granted to anyone to use this software for any purpose,
fukasawa e60969
      including commercial applications, and to alter it and redistribute
fukasawa e60969
      it freely, subject to the following restrictions:
fukasawa e60969
fukasawa e60969
      1. Redistributions of source code must retain the above copyright
fukasawa e60969
         notice, disclaimer, and this list of conditions.
fukasawa e60969
      2. Redistributions in binary form must reproduce the above copyright
fukasawa e60969
         notice, disclaimer, and this list of conditions in the documenta-
fukasawa e60969
         tion and/or other materials provided with the distribution.
fukasawa e60969
      3. All advertising materials mentioning features or use of this
fukasawa e60969
         software must display the following acknowledgment:
fukasawa e60969
fukasawa e60969
            This product includes software developed by Greg Roelofs
fukasawa e60969
            and contributors for the book, "PNG: The Definitive Guide,"
fukasawa e60969
            published by O'Reilly and Associates.
fukasawa e60969
fukasawa e60969
fukasawa e60969
      LICENSE 2 (GNU GPL v2 or later):
fukasawa e60969
fukasawa e60969
      This program is free software; you can redistribute it and/or modify
fukasawa e60969
      it under the terms of the GNU General Public License as published by
fukasawa e60969
      the Free Software Foundation; either version 2 of the License, or
fukasawa e60969
      (at your option) any later version.
fukasawa e60969
fukasawa e60969
      This program is distributed in the hope that it will be useful,
fukasawa e60969
      but WITHOUT ANY WARRANTY; without even the implied warranty of
fukasawa e60969
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
fukasawa e60969
      GNU General Public License for more details.
fukasawa e60969
fukasawa e60969
      You should have received a copy of the GNU General Public License
fukasawa e60969
      along with this program; if not, write to the Free Software Foundation,
fukasawa e60969
      Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
fukasawa e60969
fukasawa e60969
  ---------------------------------------------------------------------------*/
fukasawa e60969
fukasawa e60969
#ifndef TRUE
fukasawa e60969
#  define TRUE 1
fukasawa e60969
#  define FALSE 0
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
#ifndef MAX
fukasawa e60969
#  define MAX(a,b)  ((a) > (b)? (a) : (b))
fukasawa e60969
#  define MIN(a,b)  ((a) < (b)? (a) : (b))
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
#ifdef DEBUG
fukasawa e60969
#  define Trace(x)  {fprintf x ; fflush(stderr); fflush(stdout);}
fukasawa e60969
#else
fukasawa e60969
#  define Trace(x)  ;
fukasawa e60969
#endif
fukasawa e60969
fukasawa e60969
#define TEXT_TITLE    0x01
fukasawa e60969
#define TEXT_AUTHOR   0x02
fukasawa e60969
#define TEXT_DESC     0x04
fukasawa e60969
#define TEXT_COPY     0x08
fukasawa e60969
#define TEXT_EMAIL    0x10
fukasawa e60969
#define TEXT_URL      0x20
fukasawa e60969
fukasawa e60969
#define TEXT_TITLE_OFFSET        0
fukasawa e60969
#define TEXT_AUTHOR_OFFSET      72
fukasawa e60969
#define TEXT_COPY_OFFSET     (2*72)
fukasawa e60969
#define TEXT_EMAIL_OFFSET    (3*72)
fukasawa e60969
#define TEXT_URL_OFFSET      (4*72)
fukasawa e60969
#define TEXT_DESC_OFFSET     (5*72)
fukasawa e60969
fukasawa e60969
typedef unsigned char   uch;
fukasawa e60969
typedef unsigned short  ush;
fukasawa e60969
typedef unsigned long   ulg;
fukasawa e60969
fukasawa e60969
typedef struct _mainprog_info {
fukasawa e60969
    double gamma;
fukasawa e60969
    long width;
fukasawa e60969
    long height;
fukasawa e60969
    time_t modtime;
fukasawa e60969
    FILE *infile;
fukasawa e60969
    FILE *outfile;
fukasawa e60969
    void *png_ptr;
fukasawa e60969
    void *info_ptr;
fukasawa e60969
    uch *image_data;
fukasawa e60969
    uch **row_pointers;
fukasawa e60969
    char *title;
fukasawa e60969
    char *author;
fukasawa e60969
    char *desc;
fukasawa e60969
    char *copyright;
fukasawa e60969
    char *email;
fukasawa e60969
    char *url;
fukasawa e60969
    int filter;    /* command-line-filter flag, not PNG row filter! */
fukasawa e60969
    int pnmtype;
fukasawa e60969
    int sample_depth;
fukasawa e60969
    int interlaced;
fukasawa e60969
    int have_bg;
fukasawa e60969
    int have_time;
fukasawa e60969
    int have_text;
fukasawa e60969
    jmp_buf jmpbuf;
fukasawa e60969
    uch bg_red;
fukasawa e60969
    uch bg_green;
fukasawa e60969
    uch bg_blue;
fukasawa e60969
} mainprog_info;
fukasawa e60969
fukasawa e60969
fukasawa e60969
/* prototypes for public functions in writepng.c */
fukasawa e60969
fukasawa e60969
void writepng_version_info(void);
fukasawa e60969
fukasawa e60969
int writepng_init(mainprog_info *mainprog_ptr);
fukasawa e60969
fukasawa e60969
int writepng_encode_image(mainprog_info *mainprog_ptr);
fukasawa e60969
fukasawa e60969
int writepng_encode_row(mainprog_info *mainprog_ptr);
fukasawa e60969
fukasawa e60969
int writepng_encode_finish(mainprog_info *mainprog_ptr);
fukasawa e60969
fukasawa e60969
void writepng_cleanup(mainprog_info *mainprog_ptr);