diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-02-08 01:14:29 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-02-08 01:14:29 +0000 |
commit | 56647275b5f108e7116aee2ecb27b7e4b47c5600 (patch) | |
tree | bb24a18f027bd4c9e921a96193938fd8a5216967 | |
parent | cb0c5a3c03bb141139e5442d328663352edee134 (diff) | |
download | rockbox-56647275b5f108e7116aee2ecb27b7e4b47c5600.tar.gz rockbox-56647275b5f108e7116aee2ecb27b7e4b47c5600.zip |
JPEG viewer adapted to colour targets (greyscale only for now). New functions in the lcd extensions plugin library for drawing canonical greyscale bitmaps.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8617 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugins/jpeg.c | 79 | ||||
-rw-r--r-- | apps/plugins/lib/xlcd.c | 132 | ||||
-rw-r--r-- | apps/plugins/lib/xlcd.h | 7 |
3 files changed, 199 insertions, 19 deletions
diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c index 37c5ed6c99..e24c048ae8 100644 --- a/apps/plugins/jpeg.c +++ b/apps/plugins/jpeg.c | |||
@@ -23,11 +23,11 @@ | |||
23 | * | 23 | * |
24 | ****************************************************************************/ | 24 | ****************************************************************************/ |
25 | 25 | ||
26 | #ifndef SIMULATOR /* not for simulator by now */ | ||
27 | #include "plugin.h" | 26 | #include "plugin.h" |
28 | 27 | ||
29 | #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) | 28 | #if defined(HAVE_LCD_BITMAP) && ((LCD_DEPTH >= 8) || !defined(SIMULATOR)) |
30 | #include "gray.h" | 29 | #include "gray.h" |
30 | #include "xlcd.h" | ||
31 | 31 | ||
32 | PLUGIN_HEADER | 32 | PLUGIN_HEADER |
33 | 33 | ||
@@ -51,7 +51,8 @@ PLUGIN_HEADER | |||
51 | #define JPEG_RIGHT BUTTON_RIGHT | 51 | #define JPEG_RIGHT BUTTON_RIGHT |
52 | #define JPEG_QUIT BUTTON_OFF | 52 | #define JPEG_QUIT BUTTON_OFF |
53 | 53 | ||
54 | #elif CONFIG_KEYPAD == IRIVER_H100_PAD | 54 | #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ |
55 | (CONFIG_KEYPAD == IRIVER_H300_PAD) | ||
55 | #define JPEG_ZOOM_IN BUTTON_SELECT | 56 | #define JPEG_ZOOM_IN BUTTON_SELECT |
56 | #define JPEG_ZOOM_OUT BUTTON_MODE | 57 | #define JPEG_ZOOM_OUT BUTTON_MODE |
57 | #define JPEG_UP BUTTON_UP | 58 | #define JPEG_UP BUTTON_UP |
@@ -69,6 +70,27 @@ PLUGIN_HEADER | |||
69 | #define JPEG_RIGHT BUTTON_RIGHT | 70 | #define JPEG_RIGHT BUTTON_RIGHT |
70 | #define JPEG_QUIT BUTTON_SELECT | 71 | #define JPEG_QUIT BUTTON_SELECT |
71 | 72 | ||
73 | #elif CONFIG_KEYPAD == IAUDIO_X5_PAD | ||
74 | #define JPEG_ZOOM_IN_PRE BUTTON_MENU | ||
75 | #define JPEG_ZOOM_IN (BUTTON_MENU | BUTTON_REL) | ||
76 | #define JPEG_ZOOM_OUT (BUTTON_MENU | BUTTON_REPEAT) | ||
77 | #define JPEG_UP BUTTON_UP | ||
78 | #define JPEG_DOWN BUTTON_DOWN | ||
79 | #define JPEG_LEFT BUTTON_LEFT | ||
80 | #define JPEG_RIGHT BUTTON_RIGHT | ||
81 | #define JPEG_QUIT BUTTON_POWER | ||
82 | #endif | ||
83 | |||
84 | /* different graphics libraries */ | ||
85 | #if LCD_DEPTH < 8 | ||
86 | #define USEGSLIB | ||
87 | #define MYLCD(fn) gray_ub_ ## fn | ||
88 | #define MYLCD_UPDATE() | ||
89 | #define MYXLCD(fn) gray_ub_ ## fn | ||
90 | #else | ||
91 | #define MYLCD(fn) rb->lcd_ ## fn | ||
92 | #define MYLCD_UPDATE() rb->lcd_update(); | ||
93 | #define MYXLCD(fn) xlcd_ ## fn | ||
72 | #endif | 94 | #endif |
73 | 95 | ||
74 | /******************************* Globals ***********************************/ | 96 | /******************************* Globals ***********************************/ |
@@ -1538,8 +1560,9 @@ int root_size; | |||
1538 | void cleanup(void *parameter) | 1560 | void cleanup(void *parameter) |
1539 | { | 1561 | { |
1540 | (void)parameter; | 1562 | (void)parameter; |
1541 | 1563 | #ifdef USEGSLIB | |
1542 | gray_show(false); | 1564 | gray_show(false); |
1565 | #endif | ||
1543 | } | 1566 | } |
1544 | 1567 | ||
1545 | #define VSCROLL (LCD_HEIGHT/8) | 1568 | #define VSCROLL (LCD_HEIGHT/8) |
@@ -1570,12 +1593,13 @@ int scroll_bmp(struct t_disp* pdisp) | |||
1570 | move = MIN(HSCROLL, pdisp->x); | 1593 | move = MIN(HSCROLL, pdisp->x); |
1571 | if (move > 0) | 1594 | if (move > 0) |
1572 | { | 1595 | { |
1573 | gray_ub_scroll_right(move); /* scroll right */ | 1596 | MYXLCD(scroll_right)(move); /* scroll right */ |
1574 | pdisp->x -= move; | 1597 | pdisp->x -= move; |
1575 | gray_ub_gray_bitmap_part( | 1598 | MYXLCD(gray_bitmap_part)( |
1576 | pdisp->bitmap, pdisp->x, pdisp->y, pdisp->stride, | 1599 | pdisp->bitmap, pdisp->x, pdisp->y, pdisp->stride, |
1577 | 0, MAX(0, (LCD_HEIGHT-pdisp->height)/2), /* x, y */ | 1600 | 0, MAX(0, (LCD_HEIGHT-pdisp->height)/2), /* x, y */ |
1578 | move, MIN(LCD_HEIGHT, pdisp->height)); /* w, h */ | 1601 | move, MIN(LCD_HEIGHT, pdisp->height)); /* w, h */ |
1602 | MYLCD_UPDATE(); | ||
1579 | } | 1603 | } |
1580 | break; | 1604 | break; |
1581 | 1605 | ||
@@ -1584,13 +1608,14 @@ int scroll_bmp(struct t_disp* pdisp) | |||
1584 | move = MIN(HSCROLL, pdisp->width - pdisp->x - LCD_WIDTH); | 1608 | move = MIN(HSCROLL, pdisp->width - pdisp->x - LCD_WIDTH); |
1585 | if (move > 0) | 1609 | if (move > 0) |
1586 | { | 1610 | { |
1587 | gray_ub_scroll_left(move); /* scroll left */ | 1611 | MYXLCD(scroll_left)(move); /* scroll left */ |
1588 | pdisp->x += move; | 1612 | pdisp->x += move; |
1589 | gray_ub_gray_bitmap_part( | 1613 | MYXLCD(gray_bitmap_part)( |
1590 | pdisp->bitmap, pdisp->x + LCD_WIDTH - move, | 1614 | pdisp->bitmap, pdisp->x + LCD_WIDTH - move, |
1591 | pdisp->y, pdisp->stride, | 1615 | pdisp->y, pdisp->stride, |
1592 | LCD_WIDTH - move, MAX(0, (LCD_HEIGHT-pdisp->height)/2), /* x, y */ | 1616 | LCD_WIDTH - move, MAX(0, (LCD_HEIGHT-pdisp->height)/2), /* x, y */ |
1593 | move, MIN(LCD_HEIGHT, pdisp->height)); /* w, h */ | 1617 | move, MIN(LCD_HEIGHT, pdisp->height)); /* w, h */ |
1618 | MYLCD_UPDATE(); | ||
1594 | } | 1619 | } |
1595 | break; | 1620 | break; |
1596 | 1621 | ||
@@ -1599,12 +1624,13 @@ int scroll_bmp(struct t_disp* pdisp) | |||
1599 | move = MIN(VSCROLL, pdisp->y); | 1624 | move = MIN(VSCROLL, pdisp->y); |
1600 | if (move > 0) | 1625 | if (move > 0) |
1601 | { | 1626 | { |
1602 | gray_ub_scroll_down(move); /* scroll down */ | 1627 | MYXLCD(scroll_down)(move); /* scroll down */ |
1603 | pdisp->y -= move; | 1628 | pdisp->y -= move; |
1604 | gray_ub_gray_bitmap_part( | 1629 | MYXLCD(gray_bitmap_part)( |
1605 | pdisp->bitmap, pdisp->x, pdisp->y, pdisp->stride, | 1630 | pdisp->bitmap, pdisp->x, pdisp->y, pdisp->stride, |
1606 | MAX(0, (LCD_WIDTH-pdisp->width)/2), 0, /* x, y */ | 1631 | MAX(0, (LCD_WIDTH-pdisp->width)/2), 0, /* x, y */ |
1607 | MIN(LCD_WIDTH, pdisp->width), move); /* w, h */ | 1632 | MIN(LCD_WIDTH, pdisp->width), move); /* w, h */ |
1633 | MYLCD_UPDATE(); | ||
1608 | } | 1634 | } |
1609 | break; | 1635 | break; |
1610 | 1636 | ||
@@ -1613,13 +1639,14 @@ int scroll_bmp(struct t_disp* pdisp) | |||
1613 | move = MIN(VSCROLL, pdisp->height - pdisp->y - LCD_HEIGHT); | 1639 | move = MIN(VSCROLL, pdisp->height - pdisp->y - LCD_HEIGHT); |
1614 | if (move > 0) | 1640 | if (move > 0) |
1615 | { | 1641 | { |
1616 | gray_ub_scroll_up(move); /* scroll up */ | 1642 | MYXLCD(scroll_up)(move); /* scroll up */ |
1617 | pdisp->y += move; | 1643 | pdisp->y += move; |
1618 | gray_ub_gray_bitmap_part( | 1644 | MYXLCD(gray_bitmap_part)( |
1619 | pdisp->bitmap, pdisp->x, | 1645 | pdisp->bitmap, pdisp->x, |
1620 | pdisp->y + LCD_HEIGHT - move, pdisp->stride, | 1646 | pdisp->y + LCD_HEIGHT - move, pdisp->stride, |
1621 | MAX(0, (LCD_WIDTH-pdisp->width)/2), LCD_HEIGHT - move, /* x, y */ | 1647 | MAX(0, (LCD_WIDTH-pdisp->width)/2), LCD_HEIGHT - move, /* x, y */ |
1622 | MIN(LCD_WIDTH, pdisp->width), move); /* w, h */ | 1648 | MIN(LCD_WIDTH, pdisp->width), move); /* w, h */ |
1649 | MYLCD_UPDATE(); | ||
1623 | } | 1650 | } |
1624 | break; | 1651 | break; |
1625 | 1652 | ||
@@ -1821,12 +1848,14 @@ void get_view(struct t_disp* p_disp, int* p_cx, int* p_cy) | |||
1821 | 1848 | ||
1822 | 1849 | ||
1823 | /* load, decode, display the image */ | 1850 | /* load, decode, display the image */ |
1824 | int main(char* filename) | 1851 | int plugin_main(char* filename) |
1825 | { | 1852 | { |
1826 | int fd; | 1853 | int fd; |
1827 | int filesize; | 1854 | int filesize; |
1855 | #ifdef USEGSLIB | ||
1828 | int grayscales; | 1856 | int grayscales; |
1829 | long graysize; // helper | 1857 | long graysize; // helper |
1858 | #endif | ||
1830 | unsigned char* buf_jpeg; /* compressed JPEG image */ | 1859 | unsigned char* buf_jpeg; /* compressed JPEG image */ |
1831 | static struct jpeg jpg; /* too large for stack */ | 1860 | static struct jpeg jpg; /* too large for stack */ |
1832 | int status; | 1861 | int status; |
@@ -1847,6 +1876,7 @@ int main(char* filename) | |||
1847 | buf = rb->plugin_get_audio_buffer(&buf_size); /* start munching memory */ | 1876 | buf = rb->plugin_get_audio_buffer(&buf_size); /* start munching memory */ |
1848 | 1877 | ||
1849 | 1878 | ||
1879 | #ifdef USEGSLIB | ||
1850 | /* initialize the grayscale buffer: 32 bitplanes for 33 shades of gray. */ | 1880 | /* initialize the grayscale buffer: 32 bitplanes for 33 shades of gray. */ |
1851 | grayscales = gray_init(rb, buf, buf_size, false, LCD_WIDTH, LCD_HEIGHT/8, | 1881 | grayscales = gray_init(rb, buf, buf_size, false, LCD_WIDTH, LCD_HEIGHT/8, |
1852 | 32, &graysize) + 1; | 1882 | 32, &graysize) + 1; |
@@ -1858,6 +1888,9 @@ int main(char* filename) | |||
1858 | rb->close(fd); | 1888 | rb->close(fd); |
1859 | return PLUGIN_ERROR; | 1889 | return PLUGIN_ERROR; |
1860 | } | 1890 | } |
1891 | #else | ||
1892 | xlcd_init(rb); | ||
1893 | #endif | ||
1861 | 1894 | ||
1862 | 1895 | ||
1863 | /* allocate JPEG buffer */ | 1896 | /* allocate JPEG buffer */ |
@@ -1927,15 +1960,18 @@ int main(char* filename) | |||
1927 | rb->lcd_puts(0, 3, print); | 1960 | rb->lcd_puts(0, 3, print); |
1928 | rb->lcd_update(); | 1961 | rb->lcd_update(); |
1929 | 1962 | ||
1930 | gray_ub_clear_display(); | 1963 | MYLCD(clear_display)(); |
1931 | gray_ub_gray_bitmap_part( | 1964 | MYXLCD(gray_bitmap_part)( |
1932 | p_disp->bitmap, p_disp->x, p_disp->y, p_disp->stride, | 1965 | p_disp->bitmap, p_disp->x, p_disp->y, p_disp->stride, |
1933 | MAX(0, (LCD_WIDTH - p_disp->width) / 2), | 1966 | MAX(0, (LCD_WIDTH - p_disp->width) / 2), |
1934 | MAX(0, (LCD_HEIGHT - p_disp->height) / 2), | 1967 | MAX(0, (LCD_HEIGHT - p_disp->height) / 2), |
1935 | MIN(LCD_WIDTH, p_disp->width), | 1968 | MIN(LCD_WIDTH, p_disp->width), |
1936 | MIN(LCD_HEIGHT, p_disp->height)); | 1969 | MIN(LCD_HEIGHT, p_disp->height)); |
1970 | MYLCD_UPDATE(); | ||
1937 | 1971 | ||
1972 | #ifdef USEGSLIB | ||
1938 | gray_show(true); /* switch on grayscale overlay */ | 1973 | gray_show(true); /* switch on grayscale overlay */ |
1974 | #endif | ||
1939 | 1975 | ||
1940 | /* drawing is now finished, play around with scrolling | 1976 | /* drawing is now finished, play around with scrolling |
1941 | * until you press OFF or connect USB | 1977 | * until you press OFF or connect USB |
@@ -1971,12 +2007,18 @@ int main(char* filename) | |||
1971 | break; | 2007 | break; |
1972 | } | 2008 | } |
1973 | 2009 | ||
2010 | #ifdef USEGSLIB | ||
1974 | gray_show(false); /* switch off overlay */ | 2011 | gray_show(false); /* switch off overlay */ |
2012 | #else | ||
2013 | rb->lcd_clear_display(); | ||
2014 | #endif | ||
1975 | 2015 | ||
1976 | } | 2016 | } |
1977 | while (status != PLUGIN_OK && status != PLUGIN_USB_CONNECTED); | 2017 | while (status != PLUGIN_OK && status != PLUGIN_USB_CONNECTED); |
1978 | 2018 | ||
2019 | #ifdef USEGSLIB | ||
1979 | gray_release(); /* deinitialize */ | 2020 | gray_release(); /* deinitialize */ |
2021 | #endif | ||
1980 | 2022 | ||
1981 | return status; | 2023 | return status; |
1982 | } | 2024 | } |
@@ -1987,9 +2029,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
1987 | { | 2029 | { |
1988 | rb = api; /* copy to global api pointer */ | 2030 | rb = api; /* copy to global api pointer */ |
1989 | 2031 | ||
1990 | return main((char*)parameter); | 2032 | return plugin_main((char*)parameter); |
1991 | } | 2033 | } |
1992 | 2034 | ||
1993 | #endif /* #ifdef HAVE_LCD_BITMAP */ | 2035 | #endif /* HAVE_LCD_BITMAP && ((LCD_DEPTH >= 8) || !defined(SIMULATOR))*/ |
1994 | #endif /* #ifndef SIMULATOR */ | ||
1995 | 2036 | ||
diff --git a/apps/plugins/lib/xlcd.c b/apps/plugins/lib/xlcd.c index a842cf5eb7..57650ba05d 100644 --- a/apps/plugins/lib/xlcd.c +++ b/apps/plugins/lib/xlcd.c | |||
@@ -107,6 +107,138 @@ void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3) | |||
107 | 107 | ||
108 | #if LCD_DEPTH >= 8 | 108 | #if LCD_DEPTH >= 8 |
109 | 109 | ||
110 | #ifdef HAVE_LCD_COLOR | ||
111 | static const fb_data graylut[256] = { | ||
112 | #if LCD_PIXELFORMAT == RGB565 | ||
113 | 0x0000, 0x0000, 0x0000, 0x0020, 0x0020, 0x0821, 0x0821, 0x0841, | ||
114 | 0x0841, 0x0841, 0x0841, 0x0861, 0x0861, 0x1062, 0x1062, 0x1082, | ||
115 | 0x1082, 0x1082, 0x1082, 0x10a2, 0x10a2, 0x18a3, 0x18a3, 0x18c3, | ||
116 | 0x18c3, 0x18c3, 0x18c3, 0x18e3, 0x18e3, 0x20e4, 0x20e4, 0x2104, | ||
117 | 0x2104, 0x2104, 0x2104, 0x2124, 0x2124, 0x2124, 0x2925, 0x2945, | ||
118 | 0x2945, 0x2945, 0x2945, 0x2965, 0x2965, 0x2965, 0x3166, 0x3186, | ||
119 | 0x3186, 0x3186, 0x3186, 0x31a6, 0x31a6, 0x31a6, 0x39a7, 0x39c7, | ||
120 | 0x39c7, 0x39c7, 0x39c7, 0x39e7, 0x39e7, 0x39e7, 0x41e8, 0x4208, | ||
121 | 0x4208, 0x4208, 0x4208, 0x4228, 0x4228, 0x4228, 0x4a29, 0x4a49, | ||
122 | 0x4a49, 0x4a49, 0x4a49, 0x4a69, 0x4a69, 0x4a69, 0x4a69, 0x528a, | ||
123 | 0x528a, 0x528a, 0x528a, 0x52aa, 0x52aa, 0x52aa, 0x52aa, 0x5aab, | ||
124 | 0x5acb, 0x5acb, 0x5acb, 0x5acb, 0x5aeb, 0x5aeb, 0x5aeb, 0x62ec, | ||
125 | 0x630c, 0x630c, 0x630c, 0x630c, 0x632c, 0x632c, 0x632c, 0x6b2d, | ||
126 | 0x6b4d, 0x6b4d, 0x6b4d, 0x6b4d, 0x6b6d, 0x6b6d, 0x6b6d, 0x6b6d, | ||
127 | 0x738e, 0x738e, 0x738e, 0x738e, 0x73ae, 0x73ae, 0x73ae, 0x73ae, | ||
128 | 0x7bcf, 0x7bcf, 0x7bcf, 0x7bcf, 0x7bef, 0x7bef, 0x7bef, 0x7bef, | ||
129 | 0x8410, 0x8410, 0x8410, 0x8410, 0x8430, 0x8430, 0x8430, 0x8430, | ||
130 | 0x8c51, 0x8c51, 0x8c51, 0x8c51, 0x8c71, 0x8c71, 0x8c71, 0x8c71, | ||
131 | 0x9492, 0x9492, 0x9492, 0x9492, 0x94b2, 0x94b2, 0x94b2, 0x94b2, | ||
132 | 0x94d2, 0x9cd3, 0x9cd3, 0x9cd3, 0x9cf3, 0x9cf3, 0x9cf3, 0x9cf3, | ||
133 | 0x9d13, 0xa514, 0xa514, 0xa514, 0xa534, 0xa534, 0xa534, 0xa534, | ||
134 | 0xa554, 0xad55, 0xad55, 0xad55, 0xad55, 0xad75, 0xad75, 0xad75, | ||
135 | 0xad75, 0xb596, 0xb596, 0xb596, 0xb596, 0xb5b6, 0xb5b6, 0xb5b6, | ||
136 | 0xb5b6, 0xb5d6, 0xbdd7, 0xbdd7, 0xbdd7, 0xbdf7, 0xbdf7, 0xbdf7, | ||
137 | 0xbdf7, 0xbe17, 0xc618, 0xc618, 0xc618, 0xc638, 0xc638, 0xc638, | ||
138 | 0xc638, 0xc658, 0xce59, 0xce59, 0xce59, 0xce79, 0xce79, 0xce79, | ||
139 | 0xce79, 0xce99, 0xd69a, 0xd69a, 0xd69a, 0xd6ba, 0xd6ba, 0xd6ba, | ||
140 | 0xd6ba, 0xd6da, 0xd6da, 0xdedb, 0xdedb, 0xdefb, 0xdefb, 0xdefb, | ||
141 | 0xdefb, 0xdf1b, 0xdf1b, 0xe71c, 0xe71c, 0xe73c, 0xe73c, 0xe73c, | ||
142 | 0xe73c, 0xe75c, 0xe75c, 0xef5d, 0xef5d, 0xef7d, 0xef7d, 0xef7d, | ||
143 | 0xef7d, 0xef9d, 0xef9d, 0xf79e, 0xf79e, 0xf7be, 0xf7be, 0xf7be, | ||
144 | 0xf7be, 0xf7de, 0xf7de, 0xffdf, 0xffdf, 0xffff, 0xffff, 0xffff | ||
145 | #elif LCD_PIXELFORMAT == RGB565SWAPPED | ||
146 | 0x0000, 0x0000, 0x0000, 0x2000, 0x2000, 0x2108, 0x2108, 0x4108, | ||
147 | 0x4108, 0x4108, 0x4108, 0x6108, 0x6108, 0x6210, 0x6210, 0x8210, | ||
148 | 0x8210, 0x8210, 0x8210, 0xa210, 0xa210, 0xa318, 0xa318, 0xc318, | ||
149 | 0xc318, 0xc318, 0xc318, 0xe318, 0xe318, 0xe420, 0xe420, 0x0421, | ||
150 | 0x0421, 0x0421, 0x0421, 0x2421, 0x2421, 0x2421, 0x2529, 0x4529, | ||
151 | 0x4529, 0x4529, 0x4529, 0x6529, 0x6529, 0x6529, 0x6631, 0x8631, | ||
152 | 0x8631, 0x8631, 0x8631, 0xa631, 0xa631, 0xa631, 0xa739, 0xc739, | ||
153 | 0xc739, 0xc739, 0xc739, 0xe739, 0xe739, 0xe739, 0xe841, 0x0842, | ||
154 | 0x0842, 0x0842, 0x0842, 0x2842, 0x2842, 0x2842, 0x294a, 0x494a, | ||
155 | 0x494a, 0x494a, 0x494a, 0x694a, 0x694a, 0x694a, 0x694a, 0x8a52, | ||
156 | 0x8a52, 0x8a52, 0x8a52, 0xaa52, 0xaa52, 0xaa52, 0xaa52, 0xab5a, | ||
157 | 0xcb5a, 0xcb5a, 0xcb5a, 0xcb5a, 0xeb5a, 0xeb5a, 0xeb5a, 0xec62, | ||
158 | 0x0c63, 0x0c63, 0x0c63, 0x0c63, 0x2c63, 0x2c63, 0x2c63, 0x2d6b, | ||
159 | 0x4d6b, 0x4d6b, 0x4d6b, 0x4d6b, 0x6d6b, 0x6d6b, 0x6d6b, 0x6d6b, | ||
160 | 0x8e73, 0x8e73, 0x8e73, 0x8e73, 0xae73, 0xae73, 0xae73, 0xae73, | ||
161 | 0xcf7b, 0xcf7b, 0xcf7b, 0xcf7b, 0xef7b, 0xef7b, 0xef7b, 0xef7b, | ||
162 | 0x1084, 0x1084, 0x1084, 0x1084, 0x3084, 0x3084, 0x3084, 0x3084, | ||
163 | 0x518c, 0x518c, 0x518c, 0x518c, 0x718c, 0x718c, 0x718c, 0x718c, | ||
164 | 0x9294, 0x9294, 0x9294, 0x9294, 0xb294, 0xb294, 0xb294, 0xb294, | ||
165 | 0xd294, 0xd39c, 0xd39c, 0xd39c, 0xf39c, 0xf39c, 0xf39c, 0xf39c, | ||
166 | 0x139d, 0x14a5, 0x14a5, 0x14a5, 0x34a5, 0x34a5, 0x34a5, 0x34a5, | ||
167 | 0x54a5, 0x55ad, 0x55ad, 0x55ad, 0x55ad, 0x75ad, 0x75ad, 0x75ad, | ||
168 | 0x75ad, 0x96b5, 0x96b5, 0x96b5, 0x96b5, 0xb6b5, 0xb6b5, 0xb6b5, | ||
169 | 0xb6b5, 0xd6b5, 0xd7bd, 0xd7bd, 0xd7bd, 0xf7bd, 0xf7bd, 0xf7bd, | ||
170 | 0xf7bd, 0x17be, 0x18c6, 0x18c6, 0x18c6, 0x38c6, 0x38c6, 0x38c6, | ||
171 | 0x38c6, 0x58c6, 0x59ce, 0x59ce, 0x59ce, 0x79ce, 0x79ce, 0x79ce, | ||
172 | 0x79ce, 0x99ce, 0x9ad6, 0x9ad6, 0x9ad6, 0xbad6, 0xbad6, 0xbad6, | ||
173 | 0xbad6, 0xdad6, 0xdad6, 0xdbde, 0xdbde, 0xfbde, 0xfbde, 0xfbde, | ||
174 | 0xfbde, 0x1bdf, 0x1bdf, 0x1ce7, 0x1ce7, 0x3ce7, 0x3ce7, 0x3ce7, | ||
175 | 0x3ce7, 0x5ce7, 0x5ce7, 0x5def, 0x5def, 0x7def, 0x7def, 0x7def, | ||
176 | 0x7def, 0x9def, 0x9def, 0x9ef7, 0x9ef7, 0xbef7, 0xbef7, 0xbef7, | ||
177 | 0xbef7, 0xdef7, 0xdef7, 0xdfff, 0xdfff, 0xffff, 0xffff, 0xffff | ||
178 | #endif /* LCD_PIXELFORMAT */ | ||
179 | }; | ||
180 | #endif /* HAVE_LCD_COLOR */ | ||
181 | |||
182 | /* Draw a partial greyscale bitmap, canonical 8 bit format */ | ||
183 | void xlcd_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | ||
184 | int stride, int x, int y, int width, int height) | ||
185 | { | ||
186 | const unsigned char *src_end; | ||
187 | fb_data *dst; | ||
188 | |||
189 | /* nothing to draw? */ | ||
190 | if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | ||
191 | || (x + width <= 0) || (y + height <= 0)) | ||
192 | return; | ||
193 | |||
194 | /* clipping */ | ||
195 | if (x < 0) | ||
196 | { | ||
197 | width += x; | ||
198 | src_x -= x; | ||
199 | x = 0; | ||
200 | } | ||
201 | if (y < 0) | ||
202 | { | ||
203 | height += y; | ||
204 | src_y -= y; | ||
205 | y = 0; | ||
206 | } | ||
207 | if (x + width > LCD_WIDTH) | ||
208 | width = LCD_WIDTH - x; | ||
209 | if (y + height > LCD_HEIGHT) | ||
210 | height = LCD_HEIGHT - y; | ||
211 | |||
212 | src += stride * src_y + src_x; /* move starting point */ | ||
213 | src_end = src + stride * height; | ||
214 | dst = local_rb->lcd_framebuffer + LCD_WIDTH * y + x; | ||
215 | |||
216 | do | ||
217 | { | ||
218 | const unsigned char *src_row = src; | ||
219 | const unsigned char *row_end = src_row + width; | ||
220 | fb_data *dst_row = dst; | ||
221 | |||
222 | #ifdef HAVE_LCD_COLOR | ||
223 | do | ||
224 | *dst_row++ = graylut[*src_row++]; | ||
225 | while (src_row < row_end); | ||
226 | #endif | ||
227 | |||
228 | src += stride; | ||
229 | dst += LCD_WIDTH; | ||
230 | } | ||
231 | while (src < src_end); | ||
232 | } | ||
233 | |||
234 | /* Draw a full greyscale bitmap, canonical 8 bit format */ | ||
235 | void xlcd_gray_bitmap(const unsigned char *src, int x, int y, int width, | ||
236 | int height) | ||
237 | { | ||
238 | xlcd_gray_bitmap_part(src, 0, 0, width, x, y, width, height); | ||
239 | } | ||
240 | |||
241 | |||
110 | void xlcd_scroll_left(int count) | 242 | void xlcd_scroll_left(int count) |
111 | { | 243 | { |
112 | fb_data *data, *data_end; | 244 | fb_data *data, *data_end; |
diff --git a/apps/plugins/lib/xlcd.h b/apps/plugins/lib/xlcd.h index 2eaa05cd0d..b177ee5308 100644 --- a/apps/plugins/lib/xlcd.h +++ b/apps/plugins/lib/xlcd.h | |||
@@ -29,6 +29,13 @@ | |||
29 | void xlcd_init(struct plugin_api* newrb); | 29 | void xlcd_init(struct plugin_api* newrb); |
30 | void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3); | 30 | void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3); |
31 | 31 | ||
32 | #if LCD_DEPTH >= 8 | ||
33 | void xlcd_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | ||
34 | int stride, int x, int y, int width, int height); | ||
35 | void xlcd_gray_bitmap(const unsigned char *src, int x, int y, int width, | ||
36 | int height); | ||
37 | #endif | ||
38 | |||
32 | void xlcd_scroll_left(int count); | 39 | void xlcd_scroll_left(int count); |
33 | void xlcd_scroll_right(int count); | 40 | void xlcd_scroll_right(int count); |
34 | void xlcd_scroll_up(int count); | 41 | void xlcd_scroll_up(int count); |