Added missing dependencies for codeclib and pluginlib. This required renaming some...
[kugel-rb.git] / apps / plugins / test_greylib_bitmap_scale.c
blob1e45130318f0b8064597cb5e5bb89073eaa9850e
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 #include "lib/pluginlib_resize.h"
25 #include "lib/pluginlib_bmp.h"
27 #if LCD_DEPTH == 1
28 #define BMP_LOAD read_bmp_file
29 #else
30 #define BMP_LOAD rb->read_bmp_file
31 #endif
33 PLUGIN_HEADER
34 GREY_INFO_STRUCT
35 static unsigned char grey_bm_buf[LCD_WIDTH * LCD_HEIGHT +
36 BM_SCALED_SIZE(LCD_WIDTH,0,FORMAT_NATIVE,0)];
37 static unsigned char grey_display_buf[2*LCD_WIDTH * LCD_HEIGHT];
39 static const struct plugin_api* rb; /* global api struct pointer */
41 MEM_FUNCTION_WRAPPERS(rb)
43 /* this is the plugin entry point */
44 enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
46 static char filename[MAX_PATH];
47 struct bitmap grey_bm = {
48 .width = LCD_WIDTH,
49 .height = LCD_HEIGHT,
50 .data = grey_bm_buf
52 int ret, x, y;
54 if(!parameter) return PLUGIN_ERROR;
56 rb = api;
58 rb->strcpy(filename, parameter);
60 #if LCD_DEPTH == 1
61 bmp_init(rb);
62 resize_init(rb);
63 #endif
65 ret = BMP_LOAD(filename, &grey_bm, sizeof(grey_bm_buf),
66 FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_KEEP_ASPECT,
67 &format_grey);
69 if(ret < 1)
71 rb->splash(HZ*2, "failed to load bitmap");
72 return PLUGIN_ERROR;
75 long buf_taken;
76 if(!grey_init(rb, &grey_display_buf[0], sizeof(grey_display_buf), 0,
77 LCD_WIDTH, LCD_HEIGHT, &buf_taken))
79 rb->splash(HZ*2,"grey init failed");
80 return PLUGIN_ERROR;
82 grey_ub_clear_display();
83 x = (LCD_WIDTH - grey_bm.width) / 2;
84 y = (LCD_HEIGHT - grey_bm.height) / 2;
85 grey_ub_gray_bitmap(grey_bm_buf, x, y, grey_bm.width, grey_bm.height);
86 grey_show(true);
88 rb->button_get(true);
90 grey_release();
92 return PLUGIN_OK;