MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / BmpReadBitmap

Function BmpReadBitmap

src/bmp.cpp:317–338  ·  view source on GitHub ↗

* Reads the bitmap * 1 bpp and 4 bpp bitmaps are converted to 8 bpp bitmaps */

Source from the content-addressed store, hash-verified

315 * 1 bpp and 4 bpp bitmaps are converted to 8 bpp bitmaps
316 */
317bool BmpReadBitmap(RandomAccessFile &file, BmpInfo &info, BmpData &data)
318{
319 data.bitmap.resize(static_cast<size_t>(info.width) * info.height * ((info.bpp == 24) ? 3 : 1));
320
321 /* Load image */
322 file.SeekTo(info.offset, SEEK_SET);
323 switch (info.compression) {
324 case 0: // no compression
325 switch (info.bpp) {
326 case 1: return BmpRead1(file, info, data);
327 case 4: return BmpRead4(file, info, data);
328 case 8: return BmpRead8(file, info, data);
329 case 24: return BmpRead24(file, info, data);
330 default: NOT_REACHED();
331 }
332 break;
333
334 case 1: return BmpRead8Rle(file, info, data); // 8-bit RLE compression
335 case 2: return BmpRead4Rle(file, info, data); // 4-bit RLE compression
336 default: NOT_REACHED();
337 }
338}

Callers 1

ReadHeightmapBMPFunction · 0.85

Calls 9

BmpRead1Function · 0.85
BmpRead4Function · 0.85
BmpRead8Function · 0.85
BmpRead24Function · 0.85
NOT_REACHEDFunction · 0.85
BmpRead8RleFunction · 0.85
BmpRead4RleFunction · 0.85
resizeMethod · 0.80
SeekToMethod · 0.80

Tested by

no test coverage detected