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

Function BmpRead8

src/bmp.cpp:145–156  ·  view source on GitHub ↗

* Reads a 8 bpp bitmap */

Source from the content-addressed store, hash-verified

143 * Reads a 8 bpp bitmap
144 */
145static inline bool BmpRead8(RandomAccessFile &file, BmpInfo &info, BmpData &data)
146{
147 uint8_t pad = GB(4 - info.width, 0, 2);
148 for (uint y = info.height; y > 0; y--) {
149 if (file.AtEndOfFile()) return false; // the file is shorter than expected
150 uint8_t *pixel = &data.bitmap[(y - 1) * static_cast<size_t>(info.width)];
151 for (uint i = 0; i < info.width; i++) *pixel++ = file.ReadByte();
152 /* Padding for 32 bit align */
153 file.SkipBytes(pad);
154 }
155 return true;
156}
157
158/**
159 * Reads a 8-bit RLE compressed bpp bitmap

Callers 1

BmpReadBitmapFunction · 0.85

Calls 4

GBFunction · 0.85
AtEndOfFileMethod · 0.80
SkipBytesMethod · 0.80
ReadByteMethod · 0.45

Tested by

no test coverage detected