1 /*****************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// __ \_/ ___\| |/ /| __ \ / __ \ \/ /
5 * Jukebox | | ( (__) ) \___| ( | \_\ ( (__) ) (
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2009 Andrew Mahone
12 * In-memory JPEG decode test.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
26 #include "lib/jpeg_mem.h"
29 /* different graphics libraries */
33 #define MYLCD(fn) grey_ub_ ## fn
34 #define MYLCD_UPDATE()
35 #define MYXLCD(fn) grey_ub_ ## fn
36 #define CFORMAT &format_grey
38 #define MYLCD(fn) rb->lcd_ ## fn
39 #define MYLCD_UPDATE() rb->lcd_update();
40 #define MYXLCD(fn) xlcd_ ## fn
41 #define CFORMAT &format_native
44 /* this is the plugin entry point */
45 enum plugin_status
plugin_start(const void* parameter
)
47 size_t plugin_buf_len
;
48 unsigned char * plugin_buf
=
49 (unsigned char *)rb
->plugin_get_buffer(&plugin_buf_len
);
50 static char filename
[MAX_PATH
];
57 if(!parameter
) return PLUGIN_ERROR
;
59 rb
->strcpy(filename
, parameter
);
63 if (!grey_init(plugin_buf
, plugin_buf_len
, GREY_ON_COP
,
64 LCD_WIDTH
, LCD_HEIGHT
, &greysize
))
66 rb
->splash(HZ
, "grey buf error");
69 plugin_buf
+= greysize
;
70 plugin_buf_len
-= greysize
;
72 int fd
= rb
->open(filename
, O_RDONLY
);
75 unsigned long filesize
= rb
->filesize(fd
);
76 if (filesize
> plugin_buf_len
)
78 plugin_buf_len
-= filesize
;
79 unsigned char *jpeg_buf
= plugin_buf
;
80 plugin_buf
+= filesize
;
81 rb
->read(fd
, jpeg_buf
, filesize
);
84 ret
= decode_jpeg_mem(jpeg_buf
, filesize
, &bm
, plugin_buf_len
,
85 FORMAT_NATIVE
|FORMAT_RESIZE
|FORMAT_KEEP_ASPECT
,
91 grey_ub_gray_bitmap((fb_data
*)bm
.data
, (LCD_WIDTH
- bm
.width
) >> 1,
92 (LCD_HEIGHT
- bm
.height
) >> 1, bm
.width
, bm
.height
);
94 rb
->lcd_bitmap((fb_data
*)bm
.data
, (LCD_WIDTH
- bm
.width
) >> 1,
95 (LCD_HEIGHT
- bm
.height
) >> 1, bm
.width
, bm
.height
);
98 while (rb
->get_action(CONTEXT_STD
,1) != ACTION_STD_OK
) rb
->yield();