… | |
… | |
1446 | { |
1446 | { |
1447 | int sh_r, sh_g, sh_b; |
1447 | int sh_r, sh_g, sh_b; |
1448 | uint32_t mask_r, mask_g, mask_b; |
1448 | uint32_t mask_r, mask_g, mask_b; |
1449 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1449 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1450 | unsigned short low; |
1450 | unsigned short low; |
1451 | rgba high; |
|
|
1452 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1451 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1453 | |
1452 | |
1454 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1453 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1455 | |
1454 | |
1456 | /* for convenience */ |
1455 | /* for convenience */ |
… | |
… | |
1523 | tint.get (c); |
1522 | tint.get (c); |
1524 | |
1523 | |
1525 | /* prepare limits for color transformation (each channel is handled separately) */ |
1524 | /* prepare limits for color transformation (each channel is handled separately) */ |
1526 | if (shade > 100) |
1525 | if (shade > 100) |
1527 | { |
1526 | { |
1528 | high.r = c.r * (200 - shade) / 100; |
1527 | c.r = c.r * (200 - shade) / 100; |
1529 | high.g = c.g * (200 - shade) / 100; |
1528 | c.g = c.g * (200 - shade) / 100; |
1530 | high.b = c.b * (200 - shade) / 100; |
1529 | c.b = c.b * (200 - shade) / 100; |
1531 | |
1530 | |
1532 | low = 0xffff * (shade - 100) / 100; |
1531 | low = 0xffff * (shade - 100) / 100; |
1533 | } |
1532 | } |
1534 | else |
1533 | else |
1535 | { |
1534 | { |
1536 | high.r = c.r * shade / 100; |
1535 | c.r = c.r * shade / 100; |
1537 | high.g = c.g * shade / 100; |
1536 | c.g = c.g * shade / 100; |
1538 | high.b = c.b * shade / 100; |
1537 | c.b = c.b * shade / 100; |
1539 | |
1538 | |
1540 | low = 0; |
1539 | low = 0; |
1541 | } |
1540 | } |
1542 | |
1541 | |
1543 | /* fill our lookup tables */ |
1542 | /* fill our lookup tables */ |
1544 | fill_lut (lookup_r, mask_r, sh_r, low, high.r); |
1543 | fill_lut (lookup_r, mask_r, sh_r, low, c.r); |
1545 | fill_lut (lookup_g, mask_g, sh_g, low, high.g); |
1544 | fill_lut (lookup_g, mask_g, sh_g, low, c.g); |
1546 | fill_lut (lookup_b, mask_b, sh_b, low, high.b); |
1545 | fill_lut (lookup_b, mask_b, sh_b, low, c.b); |
1547 | |
1546 | |
1548 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1547 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1549 | if (ximage->bits_per_pixel == 32 |
1548 | if (ximage->bits_per_pixel == 32 |
1550 | && (ximage->depth == 24 || ximage->depth == 32) |
1549 | && (ximage->depth == 24 || ximage->depth == 32) |
1551 | && ximage->byte_order == host_byte_order) |
1550 | && ximage->byte_order == host_byte_order) |