1 /************************************************************************ 2 * apro.h 3 * 4 * Copyright (C) 1995-2002 Klaus Ehrenfried 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 * 20 *************************************************************************/ 21 22 #define UBYTE unsigned char 23 #define SHORT short 24 #define USHORT unsigned short 25 #define LONG long 26 #define ULONG unsigned long 27 28 #define FLI_MAX_X 1280 29 #define FLI_MAX_Y 1024 30 #define FLI_MAX_COLORS 256 31 #define FLI_MAX_FRAMES 4000 32 #define FLI_FILE_OLD_MAGIC 0xaf11 /* File header old Magic */ 33 #define FLI_FILE_MAGIC 0xaf12 /* File header Magic */ 34 #define FLI_FRAME_MAGIC 0xf1fa /* Frame Magic */ 35 36 #define FLI_FILE_HEADER_SIZE 128 37 #define FLI_FRAME_HEADER_SIZE 16 38 39 /* types of chunk in a fli_frame */ 40 #define FLI_256_COLOR 4 41 #define FLI_DELTA 7 42 #define FLI_64_COLOR 11 43 #define FLI_LC 12 44 #define FLI_BLACK 13 45 #define FLI_BRUN 15 46 #define FLI_COPY 16 47 48 #define IOM_SBYTE 1 49 #define IOM_UBYTE 2 50 #define IOM_SWORD 3 51 #define IOM_UWORD 4 52 #define IOM_LONG 5 53 54 #define MAP_FIRST_FRAME 1 55 #define MAP_NEXT_FRAME 2 56 #define MAP_CLOSE_LOOP 3 57 58 #define MIN_NODE_LIMIT 16 59 #define MAX_NODE_LIMIT 2048 60 #define MAXDEPTH 7 61 62 /* structures */ 63 64 typedef struct pixmap_struct 65 { 66 int width; 67 int height; 68 int len; 69 UBYTE *pixels; 70 } PMS; 71 72 typedef struct image_store_struct 73 { 74 UBYTE *pixels; /* pixels of quantized image */ 75 LONG color[FLI_MAX_COLORS]; /* color map */ 76 } ISS; 77 78 /* main or not */ 79 80 #ifdef MAIN 81 #define EXT extern 82 #else 83 #define EXT 84 #endif 85 86 /* #define BORDER_COLOR 0xFF */ 87 88 /* external variables */ 89 90 EXT LONG mem_color[FLI_MAX_COLORS]; 91 EXT int free_count[FLI_MAX_COLORS]; 92 EXT UBYTE *pixel_chunk_buffer; 93 EXT UBYTE color_chunk_buffer[3 * FLI_MAX_COLORS + 10]; 94 EXT int fli_width, fli_height, fli_size, fli_speed; 95 EXT int border_color, double_buffer; 96 EXT int Xorigin, Yorigin, Xorigin_flag, Yorigin_flag; 97 EXT int map_color_flag, use_next_flag, individual_flag; 98 EXT int wobbel_flag; 99 EXT FILE *input, *output; 100 EXT int old_format_flag; 101 EXT int node_limit, reduce_dynamics, color_depth; 102 EXT int verbose_flag,max_colors; 103 EXT int write_pal_flag; 104 EXT int filter_flag, test_magic_flag; 105 EXT char *filter_name, *tmp_file_name; 106 107 /* prototypes */ 108 109 int exitialise(int); 110 111 void get_image(char *fname, UBYTE *data, LONG color[]); 112 113 int make_fli(); 114 115 int fli_write_frame(ISS *diff, ISS *prev, ISS *curr); 116 117 void add_bytes(UBYTE record[], int *ipos, int value, int mode); 118 119 int make_color_chunk(ISS *diff, ISS *prev, ISS *curr); 120 int make_brun_chunk(UBYTE *image); 121 int make_delta_chunk(UBYTE *preprevious, UBYTE *previous, UBYTE *current); 122 int make_lc_chunk(UBYTE *preprevious, UBYTE *previous, UBYTE *current); 123 124 int get_next_line(FILE *input, char buff[], int len); 125 126 int clr_quantize(PMS *input, UBYTE *p_output, LONG color[]); 127 void prepare_quantize(); 128 void scan_rgb_image(char *file_name); 129 void add_to_large_octree(PMS *image); 130 void clear_octree(); 131 int output_palette(); 132 133 int read_image(PMS *image, char *file_name); 134 int free_pms(PMS *image); 135 int check_exist(char *file_name); 136 int read_raw(FILE *fp, char *buffer, int len); 137 138 int get_fbm_data(PMS *image, FILE *fp); 139 int get_ppm_data(PMS *image, FILE *fp, int type); 140 /* -- FIN -- */ 141