/* Copyright (c) 2010 MJ Rutter 
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA  02110-1301, USA.
 */ 


#define BMP2EPS_VER "1.16"

#define BMP 2
#define PALETTE 3
#define GREY 1
#define RGB 2

/* compression values */

#define RLE 1
#define LZW 2
#define CCITT 4
#define FLATE 8
#define RLE24 16
#define DCT 32
#define CCITTG4 64

#ifndef DEFAULT_COMPRESS
#ifdef USE_ZLIB
#define DEFAULT_COMPRESS 8
#elif defined(USE_LZW)
#define DEFAULT_COMPRESS 2
#else
#define DEFAULT_COMPRESS 1
#endif
#endif

/* flag values: low bits are debug */

#define DEBUG_MASK 7
#define HEX 256
#define EXPAND 512
#define SMOOTH 1024
#define LAND 2048
#define HEX2 4096
#define BINARY 8192
#define PAGE 16384
#define DISTILL 32768
#define PDF 65536
#define NO_TRANS 131072
#define KEEP24 262144

#define P_SHIFT 21
#define P_SUB (1<<21)
#define P_UP (1<<22)
#define P_AV (1<<23)
#define P_PAETH (1<<24)
#define PREDICT (P_SUB+P_UP+P_AV+P_PAETH)

struct bitmap{
  unsigned char *data; unsigned data_len; unsigned char *palette; int pal_len;
  int width; int height; int depth; int type; int colour; int compression;
  unsigned char *trans; int dpi_x; int dpi_y; int bb[4]; int flags;
};

/* Possible type and colour combinations:
 *
 *    Type         Colour
 *
 *    BMP          RGB or GREY
 *    PALETTE      N/A
 *    DCT          RGB or GREY
 *
 * If RGB, /DeviceRGB, if GREY /DeviceGray, if PALETTE /Indexed /DeviceRGB
 */

void compact(struct bitmap *image);
void pnmheader(FILE *pnm, int n, unsigned int *data);

