MCPcopy Create free account
hub / github.com/creatale/node-dv / getPixelColorRGBA16

Function getPixelColorRGBA16

deps/lodepng/lodepng.cpp:3471–3503  ·  view source on GitHub ↗

Get RGBA16 color of pixel with index i (y * width + x) from the raw image with given color type, but the given color type must be 16-bit itself.*/

Source from the content-addressed store, hash-verified

3469/*Get RGBA16 color of pixel with index i (y * width + x) from the raw image with
3470given color type, but the given color type must be 16-bit itself.*/
3471static void getPixelColorRGBA16(unsigned short* r, unsigned short* g, unsigned short* b, unsigned short* a,
3472 const unsigned char* in, size_t i, const LodePNGColorMode* mode)
3473{
3474 if(mode->colortype == LCT_GREY)
3475 {
3476 *r = *g = *b = 256 * in[i * 2 + 0] + in[i * 2 + 1];
3477 if(mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r) *a = 0;
3478 else *a = 65535;
3479 }
3480 else if(mode->colortype == LCT_RGB)
3481 {
3482 *r = 256u * in[i * 6 + 0] + in[i * 6 + 1];
3483 *g = 256u * in[i * 6 + 2] + in[i * 6 + 3];
3484 *b = 256u * in[i * 6 + 4] + in[i * 6 + 5];
3485 if(mode->key_defined
3486 && 256u * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r
3487 && 256u * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g
3488 && 256u * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b) *a = 0;
3489 else *a = 65535;
3490 }
3491 else if(mode->colortype == LCT_GREY_ALPHA)
3492 {
3493 *r = *g = *b = 256u * in[i * 4 + 0] + in[i * 4 + 1];
3494 *a = 256u * in[i * 4 + 2] + in[i * 4 + 3];
3495 }
3496 else if(mode->colortype == LCT_RGBA)
3497 {
3498 *r = 256u * in[i * 8 + 0] + in[i * 8 + 1];
3499 *g = 256u * in[i * 8 + 2] + in[i * 8 + 3];
3500 *b = 256u * in[i * 8 + 4] + in[i * 8 + 5];
3501 *a = 256u * in[i * 8 + 6] + in[i * 8 + 7];
3502 }
3503}
3504
3505unsigned lodepng_convert(unsigned char* out, const unsigned char* in,
3506 const LodePNGColorMode* mode_out, const LodePNGColorMode* mode_in,

Callers 2

lodepng_convertFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected