MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / getPixelColorRGBA16

Function getPixelColorRGBA16

samples/shared/lodepng.cpp:3376–3407  ·  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

3374/*Get RGBA16 color of pixel with index i (y * width + x) from the raw image with
3375given color type, but the given color type must be 16-bit itself.*/
3376static void getPixelColorRGBA16(unsigned short* r, unsigned short* g, unsigned short* b, unsigned short* a,
3377 const unsigned char* in, size_t i, const LodePNGColorMode* mode)
3378{
3379 if(mode->colortype == LCT_GREY)
3380 {
3381 *r = *g = *b = 256 * in[i * 2 + 0] + in[i * 2 + 1];
3382 if(mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r) *a = 0;
3383 else *a = 65535;
3384 }
3385 else if(mode->colortype == LCT_RGB)
3386 {
3387 *r = 256 * in[i * 6 + 0] + in[i * 6 + 1];
3388 *g = 256 * in[i * 6 + 2] + in[i * 6 + 3];
3389 *b = 256 * in[i * 6 + 4] + in[i * 6 + 5];
3390 if(mode->key_defined && 256U * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r
3391 && 256U * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g
3392 && 256U * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b) *a = 0;
3393 else *a = 65535;
3394 }
3395 else if(mode->colortype == LCT_GREY_ALPHA)
3396 {
3397 *r = *g = *b = 256 * in[i * 4 + 0] + in[i * 4 + 1];
3398 *a = 256 * in[i * 4 + 2] + in[i * 4 + 3];
3399 }
3400 else if(mode->colortype == LCT_RGBA)
3401 {
3402 *r = 256 * in[i * 8 + 0] + in[i * 8 + 1];
3403 *g = 256 * in[i * 8 + 2] + in[i * 8 + 3];
3404 *b = 256 * in[i * 8 + 4] + in[i * 8 + 5];
3405 *a = 256 * in[i * 8 + 6] + in[i * 8 + 7];
3406 }
3407}
3408
3409unsigned lodepng_convert(unsigned char* out, const unsigned char* in,
3410 LodePNGColorMode* mode_out, const LodePNGColorMode* mode_in,

Callers 2

lodepng_convertFunction · 0.85
get_color_profileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected