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.*/
| 3348 | /*Get RGBA16 color of pixel with index i (y * width + x) from the raw image with |
| 3349 | given color type, but the given color type must be 16-bit itself.*/ |
| 3350 | static unsigned getPixelColorRGBA16(unsigned short* r, unsigned short* g, unsigned short* b, unsigned short* a, |
| 3351 | const unsigned char* in, size_t i, const LodePNGColorMode* mode) |
| 3352 | { |
| 3353 | if(mode->bitdepth != 16) return 85; /*error: this function only supports 16-bit input*/ |
| 3354 | |
| 3355 | if(mode->colortype == LCT_GREY) |
| 3356 | { |
| 3357 | *r = *g = *b = 256 * in[i * 2 + 0] + in[i * 2 + 1]; |
| 3358 | if(mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r) *a = 0; |
| 3359 | else *a = 65535; |
| 3360 | } |
| 3361 | else if(mode->colortype == LCT_RGB) |
| 3362 | { |
| 3363 | *r = 256 * in[i * 6 + 0] + in[i * 6 + 1]; |
| 3364 | *g = 256 * in[i * 6 + 2] + in[i * 6 + 3]; |
| 3365 | *b = 256 * in[i * 6 + 4] + in[i * 6 + 5]; |
| 3366 | if(mode->key_defined && 256U * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r |
| 3367 | && 256U * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g |
| 3368 | && 256U * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b) *a = 0; |
| 3369 | else *a = 65535; |
| 3370 | } |
| 3371 | else if(mode->colortype == LCT_GREY_ALPHA) |
| 3372 | { |
| 3373 | *r = *g = *b = 256 * in[i * 4 + 0] + in[i * 4 + 1]; |
| 3374 | *a = 256 * in[i * 4 + 2] + in[i * 4 + 3]; |
| 3375 | } |
| 3376 | else if(mode->colortype == LCT_RGBA) |
| 3377 | { |
| 3378 | *r = 256 * in[i * 8 + 0] + in[i * 8 + 1]; |
| 3379 | *g = 256 * in[i * 8 + 2] + in[i * 8 + 3]; |
| 3380 | *b = 256 * in[i * 8 + 4] + in[i * 8 + 5]; |
| 3381 | *a = 256 * in[i * 8 + 6] + in[i * 8 + 7]; |
| 3382 | } |
| 3383 | else return 85; /*error: this function only supports 16-bit input, not palettes*/ |
| 3384 | |
| 3385 | return 0; /*no error*/ |
| 3386 | } |
| 3387 | |
| 3388 | /* |
| 3389 | converts from any color type to 24-bit or 32-bit (later maybe more supported). return value = LodePNG error code |
no outgoing calls
no test coverage detected