MCPcopy Create free account
hub / github.com/DFHack/dfhack / rgba16ToPixel

Function rgba16ToPixel

depends/lodepng/lodepng.cpp:3221–3251  ·  view source on GitHub ↗

put a pixel, given its RGBA16 color, into image of any color 16-bitdepth type*/

Source from the content-addressed store, hash-verified

3219
3220/*put a pixel, given its RGBA16 color, into image of any color 16-bitdepth type*/
3221static void rgba16ToPixel(unsigned char* out, size_t i,
3222 const LodePNGColorMode* mode,
3223 unsigned short r, unsigned short g, unsigned short b, unsigned short a) {
3224 if(mode->colortype == LCT_GREY) {
3225 unsigned short gray = r; /*((unsigned)r + g + b) / 3u;*/
3226 out[i * 2 + 0] = (gray >> 8) & 255;
3227 out[i * 2 + 1] = gray & 255;
3228 } else if(mode->colortype == LCT_RGB) {
3229 out[i * 6 + 0] = (r >> 8) & 255;
3230 out[i * 6 + 1] = r & 255;
3231 out[i * 6 + 2] = (g >> 8) & 255;
3232 out[i * 6 + 3] = g & 255;
3233 out[i * 6 + 4] = (b >> 8) & 255;
3234 out[i * 6 + 5] = b & 255;
3235 } else if(mode->colortype == LCT_GREY_ALPHA) {
3236 unsigned short gray = r; /*((unsigned)r + g + b) / 3u;*/
3237 out[i * 4 + 0] = (gray >> 8) & 255;
3238 out[i * 4 + 1] = gray & 255;
3239 out[i * 4 + 2] = (a >> 8) & 255;
3240 out[i * 4 + 3] = a & 255;
3241 } else if(mode->colortype == LCT_RGBA) {
3242 out[i * 8 + 0] = (r >> 8) & 255;
3243 out[i * 8 + 1] = r & 255;
3244 out[i * 8 + 2] = (g >> 8) & 255;
3245 out[i * 8 + 3] = g & 255;
3246 out[i * 8 + 4] = (b >> 8) & 255;
3247 out[i * 8 + 5] = b & 255;
3248 out[i * 8 + 6] = (a >> 8) & 255;
3249 out[i * 8 + 7] = a & 255;
3250 }
3251}
3252
3253/*Get RGBA8 color of pixel with index i (y * width + x) from the raw image with given color type.*/
3254static void getPixelColorRGBA8(unsigned char* r, unsigned char* g,

Callers 1

lodepng_convertFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected