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"
27 #include "lib/mylcd.h"
30 /* different graphics libraries */
34 #define CFORMAT &format_grey
36 #define CFORMAT &format_native
39 /* this is the plugin entry point */
40 enum plugin_status
plugin_start(const void* parameter
)
42 size_t plugin_buf_len
;
43 unsigned char * plugin_buf
=
44 (unsigned char *)rb
->plugin_get_buffer(&plugin_buf_len
);
45 static char filename
[MAX_PATH
];
52 if(!parameter
) return PLUGIN_ERROR
;
54 rb
->strcpy(filename
, parameter
);
58 if (!grey_init(plugin_buf
, plugin_buf_len
, GREY_ON_COP
,
59 LCD_WIDTH
, LCD_HEIGHT
, &greysize
))
61 rb
->splash(HZ
, "grey buf error");
64 plugin_buf
+= greysize
;
65 plugin_buf_len
-= greysize
;
67 int fd
= rb
->open(filename
, O_RDONLY
);
70 unsigned long filesize
= rb
->filesize(fd
);
71 if (filesize
> plugin_buf_len
)
73 plugin_buf_len
-= filesize
;
74 unsigned char *jpeg_buf
= plugin_buf
;
75 plugin_buf
+= filesize
;
76 rb
->read(fd
, jpeg_buf
, filesize
);
79 ret
= decode_jpeg_mem(jpeg_buf
, filesize
, &bm
, plugin_buf_len
,
80 FORMAT_NATIVE
|FORMAT_RESIZE
|FORMAT_KEEP_ASPECT
,
86 grey_ub_gray_bitmap((fb_data
*)bm
.data
, (LCD_WIDTH
- bm
.width
) >> 1,
87 (LCD_HEIGHT
- bm
.height
) >> 1, bm
.width
, bm
.height
);
89 rb
->lcd_bitmap((fb_data
*)bm
.data
, (LCD_WIDTH
- bm
.width
) >> 1,
90 (LCD_HEIGHT
- bm
.height
) >> 1, bm
.width
, bm
.height
);
93 while (rb
->get_action(CONTEXT_STD
,1) != ACTION_STD_OK
) rb
->yield();