Fix red in bootloaders
[maemo-rb.git] / apps / plugins / test_core_jpeg.c
blob5df69b5792da95a149e9e7e6dfb7a185c23f9a60
1 /*****************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// __ \_/ ___\| |/ /| __ \ / __ \ \/ /
5 * Jukebox | | ( (__) ) \___| ( | \_\ ( (__) ) (
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2008 Andrew Mahone
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "plugin.h"
23 #include "lib/grey.h"
24 PLUGIN_HEADER
26 /* different graphics libraries */
27 #if LCD_DEPTH < 8
28 #define USEGSLIB
29 GREY_INFO_STRUCT
30 #define MYLCD(fn) grey_ub_ ## fn
31 #define MYLCD_UPDATE()
32 #define MYXLCD(fn) grey_ub_ ## fn
33 #define CFORMAT &format_grey
34 #else
35 #define MYLCD(fn) rb->lcd_ ## fn
36 #define MYLCD_UPDATE() rb->lcd_update();
37 #define MYXLCD(fn) xlcd_ ## fn
38 #define CFORMAT NULL
39 #endif
41 /* this is the plugin entry point */
42 enum plugin_status plugin_start(const void* parameter)
44 size_t plugin_buf_len;
45 unsigned char * plugin_buf =
46 (unsigned char *)rb->plugin_get_buffer(&plugin_buf_len);
47 static char filename[MAX_PATH];
48 struct bitmap bm = {
49 .width = LCD_WIDTH,
50 .height = LCD_HEIGHT,
52 int ret;
54 if(!parameter) return PLUGIN_ERROR;
56 rb->strcpy(filename, parameter);
58 #ifdef USEGSLIB
59 long greysize;
60 if (!grey_init(plugin_buf, plugin_buf_len, GREY_ON_COP,
61 LCD_WIDTH, LCD_HEIGHT, &greysize))
63 rb->splash(HZ, "grey buf error");
64 return PLUGIN_ERROR;
66 plugin_buf += greysize;
67 plugin_buf_len -= greysize;
68 #endif
69 bm.data = plugin_buf;
70 ret = rb->read_jpeg_file(filename, &bm, plugin_buf_len,
71 FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_KEEP_ASPECT,
72 CFORMAT);
73 if (ret < 1)
74 return PLUGIN_ERROR;
75 #ifdef USEGSLIB
76 grey_show(true);
77 grey_ub_gray_bitmap((fb_data *)bm.data, (LCD_WIDTH - bm.width) >> 1,
78 (LCD_HEIGHT - bm.height) >> 1, bm.width, bm.height);
79 #else
80 rb->lcd_bitmap((fb_data *)bm.data, (LCD_WIDTH - bm.width) >> 1,
81 (LCD_HEIGHT - bm.height) >> 1, bm.width, bm.height);
82 #endif
83 MYLCD_UPDATE();
84 while (rb->get_action(CONTEXT_STD,1) != ACTION_STD_OK) rb->yield();
85 #ifdef USEGSLIB
86 grey_release();
87 #endif
88 return PLUGIN_OK;