Blame contrib/gregbook/readpng2.h

Packit 0ba690
/*---------------------------------------------------------------------------
Packit 0ba690
Packit 0ba690
   rpng2 - progressive-model PNG display program                 readpng2.h
Packit 0ba690
Packit 0ba690
  ---------------------------------------------------------------------------
Packit 0ba690
Packit 0ba690
      Copyright (c) 1998-2008 Greg Roelofs.  All rights reserved.
Packit 0ba690
Packit 0ba690
      This software is provided "as is," without warranty of any kind,
Packit 0ba690
      express or implied.  In no event shall the author or contributors
Packit 0ba690
      be held liable for any damages arising in any way from the use of
Packit 0ba690
      this software.
Packit 0ba690
Packit 0ba690
      The contents of this file are DUAL-LICENSED.  You may modify and/or
Packit 0ba690
      redistribute this software according to the terms of one of the
Packit 0ba690
      following two licenses (at your option):
Packit 0ba690
Packit 0ba690
Packit 0ba690
      LICENSE 1 ("BSD-like with advertising clause"):
Packit 0ba690
Packit 0ba690
      Permission is granted to anyone to use this software for any purpose,
Packit 0ba690
      including commercial applications, and to alter it and redistribute
Packit 0ba690
      it freely, subject to the following restrictions:
Packit 0ba690
Packit 0ba690
      1. Redistributions of source code must retain the above copyright
Packit 0ba690
         notice, disclaimer, and this list of conditions.
Packit 0ba690
      2. Redistributions in binary form must reproduce the above copyright
Packit 0ba690
         notice, disclaimer, and this list of conditions in the documenta-
Packit 0ba690
         tion and/or other materials provided with the distribution.
Packit 0ba690
      3. All advertising materials mentioning features or use of this
Packit 0ba690
         software must display the following acknowledgment:
Packit 0ba690
Packit 0ba690
            This product includes software developed by Greg Roelofs
Packit 0ba690
            and contributors for the book, "PNG: The Definitive Guide,"
Packit 0ba690
            published by O'Reilly and Associates.
Packit 0ba690
Packit 0ba690
Packit 0ba690
      LICENSE 2 (GNU GPL v2 or later):
Packit 0ba690
Packit 0ba690
      This program is free software; you can redistribute it and/or modify
Packit 0ba690
      it under the terms of the GNU General Public License as published by
Packit 0ba690
      the Free Software Foundation; either version 2 of the License, or
Packit 0ba690
      (at your option) any later version.
Packit 0ba690
Packit 0ba690
      This program is distributed in the hope that it will be useful,
Packit 0ba690
      but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 0ba690
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 0ba690
      GNU General Public License for more details.
Packit 0ba690
Packit 0ba690
      You should have received a copy of the GNU General Public License
Packit 0ba690
      along with this program; if not, write to the Free Software Foundation,
Packit 0ba690
      Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
Packit 0ba690
Packit 0ba690
  ---------------------------------------------------------------------------*/
Packit 0ba690
Packit 0ba690
#ifndef TRUE
Packit 0ba690
#  define TRUE 1
Packit 0ba690
#  define FALSE 0
Packit 0ba690
#endif
Packit 0ba690
Packit 0ba690
#ifndef MAX
Packit 0ba690
#  define MAX(a,b)  ((a) > (b)? (a) : (b))
Packit 0ba690
#  define MIN(a,b)  ((a) < (b)? (a) : (b))
Packit 0ba690
#endif
Packit 0ba690
Packit 0ba690
#ifdef DEBUG
Packit 0ba690
#  define Trace(x)  {fprintf x ; fflush(stderr); fflush(stdout);}
Packit 0ba690
#else
Packit 0ba690
#  define Trace(x)  ;
Packit 0ba690
#endif
Packit 0ba690
Packit 0ba690
enum rpng2_states {
Packit 0ba690
    kPreInit = 0,
Packit 0ba690
    kWindowInit,
Packit 0ba690
    kDone
Packit 0ba690
};
Packit 0ba690
Packit 0ba690
typedef unsigned char   uch;
Packit 0ba690
typedef unsigned short  ush;
Packit 0ba690
typedef unsigned long   ulg;
Packit 0ba690
Packit 0ba690
typedef struct _mainprog_info {
Packit 0ba690
    double display_exponent;
Packit 0ba690
    ulg width;
Packit 0ba690
    ulg height;
Packit 0ba690
    void *png_ptr;
Packit 0ba690
    void *info_ptr;
Packit 0ba690
    void (*mainprog_init)(void);
Packit 0ba690
    void (*mainprog_display_row)(ulg row_num);
Packit 0ba690
    void (*mainprog_finish_display)(void);
Packit 0ba690
    uch *image_data;
Packit 0ba690
    uch **row_pointers;
Packit 0ba690
    jmp_buf jmpbuf;
Packit 0ba690
    int passes;              /* not used */
Packit 0ba690
    int pass;
Packit 0ba690
    int rowbytes;
Packit 0ba690
    int channels;
Packit 0ba690
    int need_bgcolor;
Packit 0ba690
#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__))
Packit 0ba690
    int nommxfilters;
Packit 0ba690
    int nommxcombine;
Packit 0ba690
    int nommxinterlace;
Packit 0ba690
#endif
Packit 0ba690
    int state;
Packit 0ba690
    uch bg_red;
Packit 0ba690
    uch bg_green;
Packit 0ba690
    uch bg_blue;
Packit 0ba690
} mainprog_info;
Packit 0ba690
Packit 0ba690
Packit 0ba690
/* prototypes for public functions in readpng2.c */
Packit 0ba690
Packit 0ba690
void readpng2_version_info(void);
Packit 0ba690
Packit 0ba690
int readpng2_check_sig(uch *sig, int num);
Packit 0ba690
Packit 0ba690
int readpng2_init(mainprog_info *mainprog_ptr);
Packit 0ba690
Packit 0ba690
int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length);
Packit 0ba690
Packit 0ba690
void readpng2_cleanup(mainprog_info *mainprog_ptr);