MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / stbiw__write_pixel

Function stbiw__write_pixel

include/stb_image_write.h:287–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285}
286
287static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d)
288{
289 unsigned char bg[3] = { 255, 0, 255}, px[3];
290 int k;
291
292 if (write_alpha < 0)
293 s->func(s->context, &d[comp - 1], 1);
294
295 switch (comp) {
296 case 1:
297 s->func(s->context,d,1);
298 break;
299 case 2:
300 if (expand_mono)
301 stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp
302 else
303 s->func(s->context, d, 1); // monochrome TGA
304 break;
305 case 4:
306 if (!write_alpha) {
307 // composite against pink background
308 for (k = 0; k < 3; ++k)
309 px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255;
310 stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]);
311 break;
312 }
313 /* FALLTHROUGH */
314 case 3:
315 stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]);
316 break;
317 }
318 if (write_alpha > 0)
319 s->func(s->context, &d[comp - 1], 1);
320}
321
322static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono)
323{

Callers 2

stbiw__write_pixelsFunction · 0.85
stbi_write_tga_coreFunction · 0.85

Calls 1

stbiw__write3Function · 0.85

Tested by

no test coverage detected