MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / rgba16ToPixel

Function rgba16ToPixel

src/lodepng.cpp:3056–3097  ·  view source on GitHub ↗

put a pixel, given its RGBA16 color, into image of any color 16-bitdepth type*/

Source from the content-addressed store, hash-verified

3054
3055/*put a pixel, given its RGBA16 color, into image of any color 16-bitdepth type*/
3056static unsigned rgba16ToPixel(unsigned char* out, size_t i,
3057 const LodePNGColorMode* mode,
3058 unsigned short r, unsigned short g, unsigned short b, unsigned short a)
3059{
3060 if(mode->bitdepth != 16) return 85; /*must be 16 for this function*/
3061 if(mode->colortype == LCT_GREY)
3062 {
3063 unsigned short grey = r; /*((unsigned)r + g + b) / 3*/;
3064 out[i * 2 + 0] = (grey >> 8) & 255;
3065 out[i * 2 + 1] = grey & 255;
3066 }
3067 else if(mode->colortype == LCT_RGB)
3068 {
3069 out[i * 6 + 0] = (r >> 8) & 255;
3070 out[i * 6 + 1] = r & 255;
3071 out[i * 6 + 2] = (g >> 8) & 255;
3072 out[i * 6 + 3] = g & 255;
3073 out[i * 6 + 4] = (b >> 8) & 255;
3074 out[i * 6 + 5] = b & 255;
3075 }
3076 else if(mode->colortype == LCT_GREY_ALPHA)
3077 {
3078 unsigned short grey = r; /*((unsigned)r + g + b) / 3*/;
3079 out[i * 4 + 0] = (grey >> 8) & 255;
3080 out[i * 4 + 1] = grey & 255;
3081 out[i * 4 + 2] = (a >> 8) & 255;
3082 out[i * 4 + 3] = a & 255;
3083 }
3084 else if(mode->colortype == LCT_RGBA)
3085 {
3086 out[i * 8 + 0] = (r >> 8) & 255;
3087 out[i * 8 + 1] = r & 255;
3088 out[i * 8 + 2] = (g >> 8) & 255;
3089 out[i * 8 + 3] = g & 255;
3090 out[i * 8 + 4] = (b >> 8) & 255;
3091 out[i * 8 + 5] = b & 255;
3092 out[i * 8 + 6] = (a >> 8) & 255;
3093 out[i * 8 + 7] = a & 255;
3094 }
3095
3096 return 0; /*no error*/
3097}
3098
3099/*Get RGBA8 color of pixel with index i (y * width + x) from the raw image with given color type.*/
3100static unsigned getPixelColorRGBA8(unsigned char* r, unsigned char* g,

Callers 1

lodepng_convertFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected