1 /* Copyright (C)2004 Landmark Graphics Corporation 2 * Copyright (C)2005 Sun Microsystems, Inc. 3 * Copyright (C)2011 D. R. Commander 4 * 5 * This library is free software and may be redistributed and/or modified under 6 * the terms of the wxWindows Library License, Version 3.1 or (at your option) 7 * any later version. The full license is in the LICENSE.txt file included 8 * with this distribution. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * wxWindows Library License for more details. 14 */ 15 16 /* This provides rudimentary facilities for loading and saving true color */ 17 /* BMP and PPM files */ 18 19 #ifndef __BMP_H__ 20 #define __BMP_H__ 21 22 #define BMPPIXELFORMATS 6 23 enum BMPPIXELFORMAT {BMP_RGB=0, BMP_RGBX, BMP_BGR, BMP_BGRX, BMP_XBGR, BMP_XRGB}; 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 /* 30 * This will load a Windows bitmap from a file and return a buffer with the 31 * specified pixel format, scanline alignment, and orientation. The width and 32 * height are returned in w and h. 33 */ 34 35 int loadbmp(char *filename, unsigned char **buf, int *w, int *h, 36 enum BMPPIXELFORMAT f, int align, int dstbottomup); 37 38 /* 39 * This will save a buffer with the specified pixel format, pitch, orientation, 40 * width, and height as a 24-bit Windows bitmap or PPM (the filename determines 41 * which format to use) 42 */ 43 44 int savebmp(char *filename, unsigned char *buf, int w, int h, 45 enum BMPPIXELFORMAT f, int srcpitch, int srcbottomup); 46 47 const char *bmpgeterr(void); 48 49 #ifdef __cplusplus 50 } 51 #endif 52 53 #endif 54