@@ -149,6 +149,7 @@ struct cucul_bitmap | |||||
int red[256], green[256], blue[256], alpha[256]; | int red[256], green[256], blue[256], alpha[256]; | ||||
float gamma; | float gamma; | ||||
int gammatab[4097]; | int gammatab[4097]; | ||||
unsigned char invert; | |||||
}; | }; | ||||
#endif | #endif | ||||
@@ -313,6 +314,9 @@ struct cucul_bitmap *cucul_create_bitmap(unsigned int bpp, unsigned int w, | |||||
for(i = 0; i < 4096; i++) | for(i = 0; i < 4096; i++) | ||||
bitmap->gammatab[i] = i; | bitmap->gammatab[i] = i; | ||||
/* No color inversion by default */ | |||||
bitmap->invert = 0; | |||||
return bitmap; | return bitmap; | ||||
} | } | ||||
@@ -379,6 +383,22 @@ void cucul_set_bitmap_gamma(struct cucul_bitmap *bitmap, float gamma) | |||||
bitmap->gammatab[i] = 4096.0 * gammapow((float)i / 4096.0, 1.0 / gamma); | bitmap->gammatab[i] = 4096.0 * gammapow((float)i / 4096.0, 1.0 / gamma); | ||||
} | } | ||||
/** | |||||
* \brief Invert colors of bitmap | |||||
* | |||||
* Invert colors of bitmap | |||||
* | |||||
* \param bitmap Bitmap object. | |||||
* \param value 0 for normal behaviour, 1 for invert | |||||
*/ | |||||
void cucul_set_bitmap_invert(struct cucul_bitmap *bitmap, unsigned char value) | |||||
{ | |||||
bitmap->invert = (value==0)?0:1; | |||||
} | |||||
/** | /** | ||||
* \brief Free the memory associated with a bitmap. | * \brief Free the memory associated with a bitmap. | ||||
* | * | ||||
@@ -781,6 +801,11 @@ void cucul_draw_bitmap(cucul_t *qq, int x1, int y1, int x2, int y2, | |||||
fs_b[x+1] = 1 * error[2] / 16; | fs_b[x+1] = 1 * error[2] / 16; | ||||
} | } | ||||
if(bitmap->invert) { | |||||
outfg = 15-outfg; | |||||
outbg = 15-outfg; | |||||
} | |||||
/* Now output the character */ | /* Now output the character */ | ||||
cucul_set_color(qq, outfg, outbg); | cucul_set_color(qq, outfg, outbg); | ||||
cucul_putstr(qq, x, y, outch); | cucul_putstr(qq, x, y, outch); | ||||
@@ -223,6 +223,7 @@ void cucul_set_bitmap_palette(struct cucul_bitmap *, | |||||
unsigned int b[], unsigned int a[]); | unsigned int b[], unsigned int a[]); | ||||
void cucul_set_bitmap_gamma(struct cucul_bitmap *, float); | void cucul_set_bitmap_gamma(struct cucul_bitmap *, float); | ||||
void cucul_draw_bitmap(cucul_t *, int, int, int, int, struct cucul_bitmap const *, void *); | void cucul_draw_bitmap(cucul_t *, int, int, int, int, struct cucul_bitmap const *, void *); | ||||
void cucul_set_bitmap_invert(struct cucul_bitmap *, unsigned char); | |||||
void cucul_free_bitmap(struct cucul_bitmap *); | void cucul_free_bitmap(struct cucul_bitmap *); | ||||
/* @} */ | /* @} */ | ||||
@@ -493,7 +493,7 @@ static void demo_render(void) | |||||
//*dest++ = ((x >> 3) << 11) | ((y >> 2) << 5) | ((z >> 3)); | //*dest++ = ((x >> 3) << 11) | ((y >> 2) << 5) | ((z >> 3)); | ||||
*dest++ = (x << 16) | (y << 8) | (z); | *dest++ = (x << 16) | (y << 8) | (z); | ||||
} | } | ||||
cucul_set_bitmap_invert(bitmap, 1); | |||||
//bitmap = cucul_create_bitmap(16, 256, 256, 2 * 256, 0xf800, 0x07e0, 0x001f, 0x0000); | //bitmap = cucul_create_bitmap(16, 256, 256, 2 * 256, 0xf800, 0x07e0, 0x001f, 0x0000); | ||||
bitmap = cucul_create_bitmap(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); | bitmap = cucul_create_bitmap(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); | ||||
cucul_draw_bitmap(qq, 0, 0, cucul_get_width(qq) - 1, cucul_get_height(qq) - 1, | cucul_draw_bitmap(qq, 0, 0, cucul_get_width(qq) - 1, cucul_get_height(qq) - 1, | ||||
@@ -540,6 +540,7 @@ static void demo_render(void) | |||||
draw_circle(buffer, xo, yo, z, 0x000000ff, 200); | draw_circle(buffer, xo, yo, z, 0x000000ff, 200); | ||||
bitmap = cucul_create_bitmap(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); | bitmap = cucul_create_bitmap(32, 256, 256, 4 * 256, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); | ||||
cucul_set_bitmap_invert(bitmap, 1); | |||||
cucul_draw_bitmap(qq, 0, 0, cucul_get_width(qq) - 1, cucul_get_height(qq) - 1, bitmap, (char *)buffer); | cucul_draw_bitmap(qq, 0, 0, cucul_get_width(qq) - 1, cucul_get_height(qq) - 1, bitmap, (char *)buffer); | ||||
cucul_free_bitmap(bitmap); | cucul_free_bitmap(bitmap); | ||||
} | } | ||||