/** * Bitmap Export for Imagination Pilots Entertainment 16-bit games (IPE16) * - Blown Away - The Interactive Game by Imagination Pilots (BA) * - Panic in the Park - The Interactive Game by Imagination Pilots (PiP) * - Where's Waldo? At the Circus (Waldo1) * ART file packer and unpacker by Daniel Marschall, ViaThinkSoft (C) 2014-2018 * Revision: 2018-02-15 **/ #include #include #include #include #include #include "ipe16_bmpexport.h" #define BMP_LINE_PADDING 4 // Windows 98 does not support top-down bitmaps, so we need to flip everything #define USE_BOTTOMUP RGBQUAD ipe16_rgb_to_rgbquad(Ipe16ColorTableEntry cte) { RGBQUAD ret; ret.rgbRed = cte.r; ret.rgbGreen = cte.g; ret.rgbBlue = cte.b; ret.rgbReserved = 0; return ret; } void ipe16_write_bmp(FILE* output, unsigned int width, unsigned int height, unsigned char* imagedata, size_t imagedata_len, Ipe16ColorTable ct) { #ifdef USE_BOTTOMUP const size_t bmpDataSize = width*height; unsigned char* bmpData = (unsigned char*)malloc(bmpDataSize); assert(bmpData != NULL); int h; for (h=0; h= 0); assert(idx_dest*width >= 0); memcpy(bmpData+idx_dest*width, imagedata+idx_src*width, width); } imagedata = bmpData; #endif // Each line must be padded to a multiple of 4 int pad = (BMP_LINE_PADDING - (width % BMP_LINE_PADDING)) % BMP_LINE_PADDING; int newwidth = width+pad; int newsize = newwidth * height; unsigned char* padded_imagedata = (unsigned char*)malloc(newsize); int i; for (i=0; i