… | |
… | |
1633 | mask_r = visual->red_mask; |
1633 | mask_r = visual->red_mask; |
1634 | mask_g = visual->green_mask; |
1634 | mask_g = visual->green_mask; |
1635 | mask_b = visual->blue_mask; |
1635 | mask_b = visual->blue_mask; |
1636 | |
1636 | |
1637 | /* boring lookup table pre-initialization */ |
1637 | /* boring lookup table pre-initialization */ |
1638 | switch (srcImage->bits_per_pixel) |
1638 | switch (srcImage->depth) |
1639 | { |
1639 | { |
1640 | case 15: |
1640 | case 15: |
1641 | if ((mask_r != 0x7c00) || |
1641 | if ((mask_r != 0x7c00) || |
1642 | (mask_g != 0x03e0) || |
1642 | (mask_g != 0x03e0) || |
1643 | (mask_b != 0x001f)) |
1643 | (mask_b != 0x001f)) |
… | |
… | |
1716 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
1716 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
1717 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
1717 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
1718 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
1718 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
1719 | } |
1719 | } |
1720 | |
1720 | |
1721 | /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ |
|
|
1722 | if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000)) |
|
|
1723 | { |
|
|
1724 | unsigned int tmp; |
|
|
1725 | |
|
|
1726 | tmp = lower_lim_r; |
|
|
1727 | lower_lim_r = lower_lim_b; |
|
|
1728 | lower_lim_b = tmp; |
|
|
1729 | |
|
|
1730 | tmp = upper_lim_r; |
|
|
1731 | upper_lim_r = upper_lim_b; |
|
|
1732 | upper_lim_b = tmp; |
|
|
1733 | } |
|
|
1734 | |
|
|
1735 | /* fill our lookup tables */ |
1721 | /* fill our lookup tables */ |
1736 | for (i = 0; i <= mask_r>>sh_r; i++) |
1722 | for (i = 0; i <= mask_r>>sh_r; i++) |
1737 | { |
1723 | { |
1738 | RUINT32T tmp; |
1724 | RUINT32T tmp; |
1739 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
1725 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
… | |
… | |
1756 | } |
1742 | } |
1757 | |
1743 | |
1758 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1744 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1759 | switch (srcImage->bits_per_pixel) |
1745 | switch (srcImage->bits_per_pixel) |
1760 | { |
1746 | { |
1761 | case 15: |
|
|
1762 | { |
|
|
1763 | unsigned short *p1, *pf, *p, *pl; |
|
|
1764 | p1 = (unsigned short *) srcImage->data; |
|
|
1765 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
1766 | while (p1 < pf) |
|
|
1767 | { |
|
|
1768 | p = p1; |
|
|
1769 | pl = p1 + srcImage->width; |
|
|
1770 | for (; p < pl; p++) |
|
|
1771 | { |
|
|
1772 | *p = lookup_r[(*p & 0x7c00)>>10] | |
|
|
1773 | lookup_g[(*p & 0x03e0)>> 5] | |
|
|
1774 | lookup_b[(*p & 0x001f)]; |
|
|
1775 | } |
|
|
1776 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
1777 | } |
|
|
1778 | break; |
|
|
1779 | } |
|
|
1780 | case 16: |
|
|
1781 | { |
|
|
1782 | unsigned short *p1, *pf, *p, *pl; |
|
|
1783 | p1 = (unsigned short *) srcImage->data; |
|
|
1784 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
1785 | while (p1 < pf) |
|
|
1786 | { |
|
|
1787 | p = p1; |
|
|
1788 | pl = p1 + srcImage->width; |
|
|
1789 | for (; p < pl; p++) |
|
|
1790 | { |
|
|
1791 | *p = lookup_r[(*p & 0xf800)>>11] | |
|
|
1792 | lookup_g[(*p & 0x07e0)>> 5] | |
|
|
1793 | lookup_b[(*p & 0x001f)]; |
|
|
1794 | } |
|
|
1795 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
1796 | } |
|
|
1797 | break; |
|
|
1798 | } |
|
|
1799 | case 24: |
|
|
1800 | { |
|
|
1801 | unsigned char *p1, *pf, *p, *pl; |
|
|
1802 | p1 = (unsigned char *) srcImage->data; |
|
|
1803 | pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
1804 | while (p1 < pf) |
|
|
1805 | { |
|
|
1806 | p = p1; |
|
|
1807 | pl = p1 + srcImage->width * 3; |
|
|
1808 | for (; p < pl; p += 3) |
|
|
1809 | { |
|
|
1810 | p[0] = lookup_r[(p[0] & 0xff0000)>>16]; |
|
|
1811 | p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; |
|
|
1812 | p[2] = lookup_r[(p[2] & 0x0000ff)]; |
|
|
1813 | } |
|
|
1814 | p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
1815 | } |
|
|
1816 | break; |
|
|
1817 | } |
|
|
1818 | case 32: |
1747 | case 32: |
1819 | { |
1748 | { |
1820 | RUINT32T *p1, *pf, *p, *pl; |
1749 | RUINT32T *p1, *pf, *p, *pl; |
1821 | p1 = (RUINT32T *) srcImage->data; |
1750 | p1 = (RUINT32T *) srcImage->data; |
1822 | pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
1751 | pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
… | |
… | |
1834 | } |
1763 | } |
1835 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
1764 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
1836 | } |
1765 | } |
1837 | break; |
1766 | break; |
1838 | } |
1767 | } |
|
|
1768 | default: |
|
|
1769 | for (int y = 0; y < srcImage->height; y++) |
|
|
1770 | for (int x = 0; x < srcImage->width; x++) |
|
|
1771 | { |
|
|
1772 | unsigned long pixel = XGetPixel (srcImage, x, y); |
|
|
1773 | pixel = lookup_r[(pixel & mask_r) >> sh_r] | |
|
|
1774 | lookup_g[(pixel & mask_g) >> sh_g] | |
|
|
1775 | lookup_b[(pixel & mask_b) >> sh_b]; |
|
|
1776 | XPutPixel (srcImage, x, y, pixel); |
|
|
1777 | } |
|
|
1778 | break; |
1839 | } |
1779 | } |
1840 | |
1780 | |
1841 | free (lookup); |
1781 | free (lookup); |
1842 | } |
1782 | } |
1843 | #endif /* defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) */ |
1783 | #endif /* defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) */ |