diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-02-08 08:03:14 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-02-08 08:03:14 +0000 |
commit | 09b9a412f02ad37dca4461f428e93e7fddee7d5e (patch) | |
tree | 96f11188cf063efcaa7cf41902a10d45e42b5df6 | |
parent | b44c18ea9d9d41f59e5069669a09befc7a708c13 (diff) | |
download | rockbox-09b9a412f02ad37dca4461f428e93e7fddee7d5e.tar.gz rockbox-09b9a412f02ad37dca4461f428e93e7fddee7d5e.zip |
Preparation for colour gfx viewers: xlcd_color_bitmap_part() and xlcd_color_bitmap() added to the plugin library.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8619 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugins/lib/xlcd.c | 72 | ||||
-rw-r--r-- | apps/plugins/lib/xlcd.h | 6 |
2 files changed, 78 insertions, 0 deletions
diff --git a/apps/plugins/lib/xlcd.c b/apps/plugins/lib/xlcd.c index 57650ba05d..9ef2430d6c 100644 --- a/apps/plugins/lib/xlcd.c +++ b/apps/plugins/lib/xlcd.c | |||
@@ -238,6 +238,78 @@ void xlcd_gray_bitmap(const unsigned char *src, int x, int y, int width, | |||
238 | xlcd_gray_bitmap_part(src, 0, 0, width, x, y, width, height); | 238 | xlcd_gray_bitmap_part(src, 0, 0, width, x, y, width, height); |
239 | } | 239 | } |
240 | 240 | ||
241 | #ifdef HAVE_LCD_COLOR | ||
242 | /* Draw a partial colour bitmap, canonical 24 bit RGB format */ | ||
243 | void xlcd_color_bitmap_part(const unsigned char *src, int src_x, int src_y, | ||
244 | int stride, int x, int y, int width, int height) | ||
245 | { | ||
246 | const unsigned char *src_end; | ||
247 | fb_data *dst; | ||
248 | |||
249 | /* nothing to draw? */ | ||
250 | if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || (y >= LCD_HEIGHT) | ||
251 | || (x + width <= 0) || (y + height <= 0)) | ||
252 | return; | ||
253 | |||
254 | /* clipping */ | ||
255 | if (x < 0) | ||
256 | { | ||
257 | width += x; | ||
258 | src_x -= x; | ||
259 | x = 0; | ||
260 | } | ||
261 | if (y < 0) | ||
262 | { | ||
263 | height += y; | ||
264 | src_y -= y; | ||
265 | y = 0; | ||
266 | } | ||
267 | if (x + width > LCD_WIDTH) | ||
268 | width = LCD_WIDTH - x; | ||
269 | if (y + height > LCD_HEIGHT) | ||
270 | height = LCD_HEIGHT - y; | ||
271 | |||
272 | src += 3 * (stride * src_y + src_x); /* move starting point */ | ||
273 | src_end = src + 3 * stride * height; | ||
274 | dst = local_rb->lcd_framebuffer + LCD_WIDTH * y + x; | ||
275 | |||
276 | do | ||
277 | { | ||
278 | const unsigned char *src_row = src; | ||
279 | const unsigned char *row_end = src_row + 3 * width; | ||
280 | fb_data *dst_row = dst; | ||
281 | |||
282 | do | ||
283 | { /* only RGB565 and RGB565SWAPPED so far */ | ||
284 | unsigned red = 31 * (*src_row++) + 127; | ||
285 | unsigned green = 63 * (*src_row++) + 127; | ||
286 | unsigned blue = 31 * (*src_row++) + 127; | ||
287 | |||
288 | red = (red + (red >> 8)) >> 8; /* approx red /= 255: */ | ||
289 | green = (green + (green >> 8)) >> 8; /* approx green /= 255: */ | ||
290 | blue = (blue + (blue >> 8)) >> 8; /* approx blue /= 255: */ | ||
291 | |||
292 | #if LCD_PIXELFORMAT == RGB565 | ||
293 | *dst_row++ = (red << 11) | (green << 5) | blue; | ||
294 | #elif LCD_PIXELFORMAT == RGB565SWAPPED | ||
295 | *dst_row++ = swap16((red << 11) | (green << 5) | blue); | ||
296 | #endif | ||
297 | } | ||
298 | while (src_row < row_end); | ||
299 | |||
300 | src += stride; | ||
301 | dst += LCD_WIDTH; | ||
302 | } | ||
303 | while (src < src_end); | ||
304 | } | ||
305 | |||
306 | /* Draw a full colour bitmap, canonical 24 bit RGB format */ | ||
307 | void xlcd_color_bitmap(const unsigned char *src, int x, int y, int width, | ||
308 | int height) | ||
309 | { | ||
310 | xlcd_color_bitmap_part(src, 0, 0, width, x, y, width, height); | ||
311 | } | ||
312 | #endif /* HAVE_LCD_COLOR */ | ||
241 | 313 | ||
242 | void xlcd_scroll_left(int count) | 314 | void xlcd_scroll_left(int count) |
243 | { | 315 | { |
diff --git a/apps/plugins/lib/xlcd.h b/apps/plugins/lib/xlcd.h index b177ee5308..8f3071443e 100644 --- a/apps/plugins/lib/xlcd.h +++ b/apps/plugins/lib/xlcd.h | |||
@@ -34,6 +34,12 @@ 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); | 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, | 35 | void xlcd_gray_bitmap(const unsigned char *src, int x, int y, int width, |
36 | int height); | 36 | int height); |
37 | #ifdef HAVE_LCD_COLOR | ||
38 | void xlcd_color_bitmap_part(const unsigned char *src, int src_x, int src_y, | ||
39 | int stride, int x, int y, int width, int height); | ||
40 | void xlcd_color_bitmap(const unsigned char *src, int x, int y, int width, | ||
41 | int height); | ||
42 | #endif | ||
37 | #endif | 43 | #endif |
38 | 44 | ||
39 | void xlcd_scroll_left(int count); | 45 | void xlcd_scroll_left(int count); |