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.*/
| 3423 | /*Get RGBA16 color of pixel with index i (y * width + x) from the raw image with |
| 3424 | given color type, but the given color type must be 16-bit itself.*/ |
| 3425 | static void getPixelColorRGBA16(unsigned short* r, unsigned short* g, unsigned short* b, unsigned short* a, |
| 3426 | const unsigned char* in, size_t i, const LodePNGColorMode* mode) |
| 3427 | { |
| 3428 | if(mode->colortype == LCT_GREY) |
| 3429 | { |
| 3430 | *r = *g = *b = 256 * in[i * 2 + 0] + in[i * 2 + 1]; |
| 3431 | if(mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r) *a = 0; |
| 3432 | else *a = 65535; |
| 3433 | } |
| 3434 | else if(mode->colortype == LCT_RGB) |
| 3435 | { |
| 3436 | *r = 256u * in[i * 6 + 0] + in[i * 6 + 1]; |
| 3437 | *g = 256u * in[i * 6 + 2] + in[i * 6 + 3]; |
| 3438 | *b = 256u * in[i * 6 + 4] + in[i * 6 + 5]; |
| 3439 | if(mode->key_defined |
| 3440 | && 256u * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r |
| 3441 | && 256u * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g |
| 3442 | && 256u * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b) *a = 0; |
| 3443 | else *a = 65535; |
| 3444 | } |
| 3445 | else if(mode->colortype == LCT_GREY_ALPHA) |
| 3446 | { |
| 3447 | *r = *g = *b = 256u * in[i * 4 + 0] + in[i * 4 + 1]; |
| 3448 | *a = 256u * in[i * 4 + 2] + in[i * 4 + 3]; |
| 3449 | } |
| 3450 | else if(mode->colortype == LCT_RGBA) |
| 3451 | { |
| 3452 | *r = 256u * in[i * 8 + 0] + in[i * 8 + 1]; |
| 3453 | *g = 256u * in[i * 8 + 2] + in[i * 8 + 3]; |
| 3454 | *b = 256u * in[i * 8 + 4] + in[i * 8 + 5]; |
| 3455 | *a = 256u * in[i * 8 + 6] + in[i * 8 + 7]; |
| 3456 | } |
| 3457 | } |
| 3458 | |
| 3459 | unsigned lodepng_convert(unsigned char* out, const unsigned char* in, |
| 3460 | const LodePNGColorMode* mode_out, const LodePNGColorMode* mode_in, |
no outgoing calls
no test coverage detected