MCPcopy Create free account
hub / github.com/axmolengine/axmol / convertRG8ToRGB565

Function convertRG8ToRGB565

core/renderer/backend/PixelFormatUtils.cpp:174–183  ·  view source on GitHub ↗

IIIIIIIIAAAAAAAA -> RRRRRGGGGGGBBBBB

Source from the content-addressed store, hash-verified

172
173// IIIIIIIIAAAAAAAA -> RRRRRGGGGGGBBBBB
174static void convertRG8ToRGB565(const unsigned char* data, size_t dataLen, unsigned char* outData)
175{
176 unsigned short* out16 = (unsigned short*)outData;
177 for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2)
178 {
179 *out16++ = (data[i] & 0x00F8) << 8 // R
180 | (data[i + 1] & 0x00FC) << 3 // G
181 | (data[i] & 0x00F8) >> 3; // B
182 }
183}
184
185// IIIIIIII -> RRRRGGGGBBBBAAAA
186static void convertR8ToRGBA4(const unsigned char* data, size_t dataLen, unsigned char* outData)

Callers 1

convertRG8ToFormatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected