edit_image(): add removal of transparency with white and black
This commit is contained in:
parent
cfccb64026
commit
197379989a
15
src/draw.c
15
src/draw.c
|
|
@ -3886,6 +3886,8 @@ cairo_status_t png_writer(void *in_closure, const unsigned char *in_data, unsign
|
||||||
* 4: set black to transparent
|
* 4: set black to transparent
|
||||||
* 8: set transparent to white
|
* 8: set transparent to white
|
||||||
* 16: set transparent to black
|
* 16: set transparent to black
|
||||||
|
* 32: blend with white, remove alpha
|
||||||
|
* 64: blend with black, remove alpha
|
||||||
* 256: write back into `image_data` attribute
|
* 256: write back into `image_data` attribute
|
||||||
*/
|
*/
|
||||||
int edit_image(int what, xRect *r)
|
int edit_image(int what, xRect *r)
|
||||||
|
|
@ -3962,6 +3964,19 @@ int edit_image(int what, xRect *r)
|
||||||
if(a == 0) {r = g = b = 0x00; a = 0xff;}
|
if(a == 0) {r = g = b = 0x00; a = 0xff;}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* remove alpha, blend with white */
|
||||||
|
if(what & 32) {
|
||||||
|
r += (unsigned char)(0xff - a);
|
||||||
|
g += (unsigned char)(0xff - a);
|
||||||
|
b += (unsigned char)(0xff - a);
|
||||||
|
a = (unsigned char)0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* remove alpha, blend with black */
|
||||||
|
if(what & 64) {
|
||||||
|
a = (unsigned char)0xff;
|
||||||
|
}
|
||||||
|
|
||||||
/* write result back */
|
/* write result back */
|
||||||
ptr[3] = a;
|
ptr[3] = a;
|
||||||
ptr[2] = r;
|
ptr[2] = r;
|
||||||
|
|
|
||||||
|
|
@ -2063,6 +2063,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
||||||
if(!strcmp(argv[i], "black_transp")) what |= 4;
|
if(!strcmp(argv[i], "black_transp")) what |= 4;
|
||||||
if(!strcmp(argv[i], "transp_white")) what |= 8;
|
if(!strcmp(argv[i], "transp_white")) what |= 8;
|
||||||
if(!strcmp(argv[i], "transp_black")) what |= 16;
|
if(!strcmp(argv[i], "transp_black")) what |= 16;
|
||||||
|
if(!strcmp(argv[i], "blend_white")) what |= 32;
|
||||||
|
if(!strcmp(argv[i], "blend_black")) what |= 64;
|
||||||
if(!strcmp(argv[i], "write_back")) what |= 256;
|
if(!strcmp(argv[i], "write_back")) what |= 256;
|
||||||
}
|
}
|
||||||
if(what) {
|
if(what) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue