1 /* Copyright (C)2004 Landmark Graphics Corporation 2 * Copyright (C)2005 Sun Microsystems, Inc. 3 * Copyright (C)2011, 2014, 2017 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 #include "pf.h" 23 24 25 #define BMP_NUMORN 2 26 enum BMPORN { BMPORN_TOPDOWN = 0, BMPORN_BOTTOMUP }; 27 28 #define BMPPAD(width, align) (((width) + ((align) - 1)) & (~((align) - 1))) 29 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 /* This will load a Windows bitmap from a file and return a buffer with the 36 specified pixel format, scanline alignment, and orientation. The width and 37 height are returned in *width and *height. Use free() to free the 38 buffer once you are finished with it. */ 39 40 int bmp_load(char *filename, unsigned char **buf, int *width, int align, 41 int *height, int format, enum BMPORN orientation); 42 43 44 /* This will save a buffer with the specified pixel format, pitch, orientation, 45 width, and height as a 24-bit Windows bitmap or PPM (the filename determines 46 which format to use.) */ 47 48 int bmp_save(char *filename, unsigned char *buf, int width, int pitch, 49 int height, int format, enum BMPORN orientation); 50 51 52 const char *bmp_geterr(void); 53 54 #ifdef __cplusplus 55 } 56 #endif 57 58 #endif /* __BMP_H__ */ 59