1 /* 2 pcx.h 3 4 pcx image handling 5 6 Copyright (C) 1996-1997 Id Software, Inc. 7 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2 11 of the License, or (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 17 See the GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to: 21 22 Free Software Foundation, Inc. 23 59 Temple Place - Suite 330 24 Boston, MA 02111-1307, USA 25 */ 26 27 #ifndef __pcx_h 28 #define __pcx_h 29 30 #include "QF/qtypes.h" 31 #include "QF/quakeio.h" 32 33 /** A ZSoft PC Paintbrush (PCX) header */ 34 typedef struct 35 { 36 char manufacturer; ///< Manufacturer: Must be 10 37 char version; ///< PCX version: must be 5 38 char encoding; ///< Coding used: must be 1 39 char bits_per_pixel; ///< BPP: must be 8 for QF 40 unsigned short xmin, ymin, xmax, ymax; 41 unsigned short hres, vres; ///< resolution of image (DPI) 42 unsigned char palette[48]; 43 char reserved; ///< should be 0 44 char color_planes; ///< Number of color planes 45 unsigned short bytes_per_line; ///< Number of bytes for a scan line (per plane). According to ZSoft, must be an even number. 46 unsigned short palette_type; ///< Palette info: 1 = color, 2 = greyscale 47 char filler[58]; 48 } pcx_t; 49 50 /** 51 Convert \b paletted image data to PCX format. 52 53 \param data A pointer to the buffer containing the source image 54 \param width The width, in pixels, of the source image 55 \param height The height, in pixels, of the source image 56 \param rowbytes The number of bytes in a row of an image (usually the same 57 as the width) 58 \param palette The palette in use for the texture. 59 \param flip If true, flip the order of lines output. 60 \param[out] length The length of the encoded PCX data. 61 62 \return A pointer to the newly-coded PCX data. 63 \warning Uses Hunk_TempAlloc() to allocate the output PCX content. 64 */ 65 pcx_t *EncodePCX (byte *data, int width, int height, int rowbytes, 66 byte *palette, qboolean flip, int *length); 67 68 /** 69 Load a texture from a PCX file. 70 71 \param f The file to read the texture from 72 \param convert If true, the texture is converted to RGB on load 73 \param pal The palette to apply during conversion 74 75 \return A pointer to the texture. 76 \warning Uses Hunk_TempAlloc() to allocate the texture. 77 */ 78 struct tex_s *LoadPCX (QFile *f, qboolean convert, byte *pal); 79 80 #endif // __pcx_h 81