… | |
… | |
1453 | shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c) |
1453 | shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c) |
1454 | { |
1454 | { |
1455 | int sh_r, sh_g, sh_b; |
1455 | int sh_r, sh_g, sh_b; |
1456 | uint32_t mask_r, mask_g, mask_b; |
1456 | uint32_t mask_r, mask_g, mask_b; |
1457 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1457 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1458 | rgba low; |
1458 | unsigned short low; |
1459 | rgba high; |
1459 | rgba high; |
1460 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1460 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1461 | |
1461 | |
1462 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1462 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1463 | |
1463 | |
… | |
… | |
1532 | |
1532 | |
1533 | high.r = c.r * shade / 100; |
1533 | high.r = c.r * shade / 100; |
1534 | high.g = c.g * shade / 100; |
1534 | high.g = c.g * shade / 100; |
1535 | high.b = c.b * shade / 100; |
1535 | high.b = c.b * shade / 100; |
1536 | |
1536 | |
1537 | low.r = 65535 * (100 - shade) / 100; |
1537 | low = 0xffff * (100 - shade) / 100; |
1538 | low.g = 65535 * (100 - shade) / 100; |
|
|
1539 | low.b = 65535 * (100 - shade) / 100; |
|
|
1540 | } |
1538 | } |
1541 | else |
1539 | else |
1542 | { |
1540 | { |
1543 | high.r = c.r * shade / 100; |
1541 | high.r = c.r * shade / 100; |
1544 | high.g = c.g * shade / 100; |
1542 | high.g = c.g * shade / 100; |
1545 | high.b = c.b * shade / 100; |
1543 | high.b = c.b * shade / 100; |
1546 | |
1544 | |
1547 | low.r = low.g = low.b = 0; |
1545 | low = 0; |
1548 | } |
1546 | } |
1549 | |
1547 | |
1550 | /* fill our lookup tables */ |
1548 | /* fill our lookup tables */ |
1551 | fill_lut (lookup_r, mask_r, sh_r, low.r, high.r); |
1549 | fill_lut (lookup_r, mask_r, sh_r, low, high.r); |
1552 | fill_lut (lookup_g, mask_g, sh_g, low.g, high.g); |
1550 | fill_lut (lookup_g, mask_g, sh_g, low, high.g); |
1553 | fill_lut (lookup_b, mask_b, sh_b, low.b, high.b); |
1551 | fill_lut (lookup_b, mask_b, sh_b, low, high.b); |
1554 | |
1552 | |
1555 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1553 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1556 | if (ximage->bits_per_pixel == 32 |
1554 | if (ximage->bits_per_pixel == 32 |
1557 | && (ximage->depth == 24 || ximage->depth == 32) |
1555 | && (ximage->depth == 24 || ximage->depth == 32) |
1558 | && ximage->byte_order == host_byte_order) |
1556 | && ximage->byte_order == host_byte_order) |