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.*/
| 3496 | /*Get RGBA16 color of pixel with index i (y * width + x) from the raw image with |
| 3497 | given color type, but the given color type must be 16-bit itself.*/ |
| 3498 | static void getPixelColorRGBA16(unsigned short* r, unsigned short* g, unsigned short* b, unsigned short* a, |
| 3499 | const unsigned char* in, size_t i, const LodePNGColorMode* mode) { |
| 3500 | if(mode->colortype == LCT_GREY) { |
| 3501 | *r = *g = *b = 256 * in[i * 2 + 0] + in[i * 2 + 1]; |
| 3502 | if(mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r) *a = 0; |
| 3503 | else *a = 65535; |
| 3504 | } else if(mode->colortype == LCT_RGB) { |
| 3505 | *r = 256u * in[i * 6 + 0] + in[i * 6 + 1]; |
| 3506 | *g = 256u * in[i * 6 + 2] + in[i * 6 + 3]; |
| 3507 | *b = 256u * in[i * 6 + 4] + in[i * 6 + 5]; |
| 3508 | if(mode->key_defined |
| 3509 | && 256u * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r |
| 3510 | && 256u * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g |
| 3511 | && 256u * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b) *a = 0; |
| 3512 | else *a = 65535; |
| 3513 | } else if(mode->colortype == LCT_GREY_ALPHA) { |
| 3514 | *r = *g = *b = 256u * in[i * 4 + 0] + in[i * 4 + 1]; |
| 3515 | *a = 256u * in[i * 4 + 2] + in[i * 4 + 3]; |
| 3516 | } else if(mode->colortype == LCT_RGBA) { |
| 3517 | *r = 256u * in[i * 8 + 0] + in[i * 8 + 1]; |
| 3518 | *g = 256u * in[i * 8 + 2] + in[i * 8 + 3]; |
| 3519 | *b = 256u * in[i * 8 + 4] + in[i * 8 + 5]; |
| 3520 | *a = 256u * in[i * 8 + 6] + in[i * 8 + 7]; |
| 3521 | } |
| 3522 | } |
| 3523 | |
| 3524 | unsigned lodepng_convert(unsigned char* out, const unsigned char* in, |
| 3525 | const LodePNGColorMode* mode_out, const LodePNGColorMode* mode_in, |
no outgoing calls
no test coverage detected