MCPcopy Create free account
hub / github.com/HiLab-git/SimpleCRF / rgba16ToPixel

Function rgba16ToPixel

dependency/densecrf/examples/lodepng.cpp:3140–3178  ·  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

3138
3139/*put a pixel, given its RGBA16 color, into image of any color 16-bitdepth type*/
3140static void rgba16ToPixel(unsigned char* out, size_t i,
3141 const LodePNGColorMode* mode,
3142 unsigned short r, unsigned short g, unsigned short b, unsigned short a)
3143{
3144 if(mode->colortype == LCT_GREY)
3145 {
3146 unsigned short grey = r; /*((unsigned)r + g + b) / 3*/;
3147 out[i * 2 + 0] = (grey >> 8) & 255;
3148 out[i * 2 + 1] = grey & 255;
3149 }
3150 else if(mode->colortype == LCT_RGB)
3151 {
3152 out[i * 6 + 0] = (r >> 8) & 255;
3153 out[i * 6 + 1] = r & 255;
3154 out[i * 6 + 2] = (g >> 8) & 255;
3155 out[i * 6 + 3] = g & 255;
3156 out[i * 6 + 4] = (b >> 8) & 255;
3157 out[i * 6 + 5] = b & 255;
3158 }
3159 else if(mode->colortype == LCT_GREY_ALPHA)
3160 {
3161 unsigned short grey = r; /*((unsigned)r + g + b) / 3*/;
3162 out[i * 4 + 0] = (grey >> 8) & 255;
3163 out[i * 4 + 1] = grey & 255;
3164 out[i * 4 + 2] = (a >> 8) & 255;
3165 out[i * 4 + 3] = a & 255;
3166 }
3167 else if(mode->colortype == LCT_RGBA)
3168 {
3169 out[i * 8 + 0] = (r >> 8) & 255;
3170 out[i * 8 + 1] = r & 255;
3171 out[i * 8 + 2] = (g >> 8) & 255;
3172 out[i * 8 + 3] = g & 255;
3173 out[i * 8 + 4] = (b >> 8) & 255;
3174 out[i * 8 + 5] = b & 255;
3175 out[i * 8 + 6] = (a >> 8) & 255;
3176 out[i * 8 + 7] = a & 255;
3177 }
3178}
3179
3180/*Get RGBA8 color of pixel with index i (y * width + x) from the raw image with given color type.*/
3181static void getPixelColorRGBA8(unsigned char* r, unsigned char* g,

Callers 1

lodepng_convertFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected