- switch(get_color_model())
- {
- case BC_RGB888:
- DRAW_PIXEL(x, y, 3, 0, 0xff, unsigned char);
- break;
- case BC_RGBA8888:
- DRAW_PIXEL(x, y, 4, 0, 0xff, unsigned char);
- break;
- case BC_RGB_FLOAT:
- DRAW_PIXEL(x, y, 3, 0, 1.0, float);
- break;
- case BC_RGBA_FLOAT:
- DRAW_PIXEL(x, y, 4, 0, 1.0, float);
- break;
- case BC_YUV888:
- DRAW_PIXEL(x, y, 3, 1, 0xff, unsigned char);
- break;
- case BC_YUVA8888:
- DRAW_PIXEL(x, y, 4, 1, 0xff, unsigned char);
- break;
- case BC_RGB161616:
- DRAW_PIXEL(x, y, 3, 0, 0xffff, uint16_t);
- break;
- case BC_YUV161616:
- DRAW_PIXEL(x, y, 3, 1, 0xffff, uint16_t);
- break;
- case BC_RGBA16161616:
- DRAW_PIXEL(x, y, 4, 0, 0xffff, uint16_t);
- break;
- case BC_YUVA16161616:
- DRAW_PIXEL(x, y, 4, 1, 0xffff, uint16_t);
- break;
+#define DRAW_PIXEL(type, r, g, b) { \
+ type **rows = (type**)get_rows(); \
+ rows[y][x * components + 0] = r; \
+ rows[y][x * components + 1] = g; \
+ rows[y][x * components + 2] = b; \
+ if( components == 4 ) \
+ rows[y][x * components + 3] = mx; \
+}
+ int components = BC_CModels::components(color_model);
+ int bch = BC_CModels::calculate_pixelsize(color_model) / components;
+ int sz = 8*bch, mx = BC_CModels::is_float(color_model) ? 1 : (1<<sz)-1;
+ int is_yuv = BC_CModels::is_yuv(color_model);
+ int pixel_color = is_yuv ? pixel_yuv : pixel_rgb;
+ int ir = 0xff & (pixel_color >> 16); float fr = 0;
+ int ig = 0xff & (pixel_color >> 8); float fg = 0;
+ int ib = 0xff & (pixel_color >> 0); float fb = 0;
+ if( (x+y) & stipple ) {
+ ir = 255 - ir; ig = 255 - ig; ib = 255 - ib;
+ }
+ if( BC_CModels::is_float(color_model) ) {
+ fr = ir / 255.; fg = ig / 255.; fb = ib / 255.;
+ mx = 1;
+ }
+ else if( (sz-=8) > 0 ) {
+ ir <<= sz; ig <<= sz; ib <<= sz;
+ }
+
+ switch(get_color_model()) {
+ case BC_RGB888:
+ case BC_YUV888:
+ case BC_RGBA8888:
+ case BC_YUVA8888:
+ DRAW_PIXEL(uint8_t, ir, ig, ib);
+ break;
+ case BC_RGB161616:
+ case BC_YUV161616:
+ case BC_RGBA16161616:
+ case BC_YUVA16161616:
+ DRAW_PIXEL(uint16_t, ir, ig, ib);
+ break;
+ case BC_RGB_FLOAT:
+ case BC_RGBA_FLOAT:
+ DRAW_PIXEL(float, fr, fg, fb);
+ break;