fukasawa e60969
/*---------------------------------------------------------------------------
fukasawa e60969
fukasawa e60969
   rpng2 - progressive-model PNG display program                 readpng2.h
fukasawa e60969
fukasawa e60969
  ---------------------------------------------------------------------------
fukasawa e60969
fukasawa e60969
      Copyright (c) 1998-2008 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
enum rpng2_states {
fukasawa e60969
    kPreInit = 0,
fukasawa e60969
    kWindowInit,
fukasawa e60969
    kDone
fukasawa e60969
};
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 display_exponent;
fukasawa e60969
    ulg width;
fukasawa e60969
    ulg height;
fukasawa e60969
    void *png_ptr;
fukasawa e60969
    void *info_ptr;
fukasawa e60969
    void (*mainprog_init)(void);
fukasawa e60969
    void (*mainprog_display_row)(ulg row_num);
fukasawa e60969
    void (*mainprog_finish_display)(void);
fukasawa e60969
    uch *image_data;
fukasawa e60969
    uch **row_pointers;
fukasawa e60969
    jmp_buf jmpbuf;
fukasawa e60969
    int passes;              /* not used */
fukasawa e60969
    int pass;
fukasawa e60969
    int rowbytes;
fukasawa e60969
    int channels;
fukasawa e60969
    int need_bgcolor;
fukasawa e60969
    int state;
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 readpng2.c */
fukasawa e60969
fukasawa e60969
void readpng2_version_info(void);
fukasawa e60969
fukasawa e60969
int readpng2_check_sig(uch *sig, int num);
fukasawa e60969
fukasawa e60969
int readpng2_init(mainprog_info *mainprog_ptr);
fukasawa e60969
fukasawa e60969
int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length);
fukasawa e60969
fukasawa e60969
void readpng2_cleanup(mainprog_info *mainprog_ptr);