as3525: fix r26308
[kugel-rb.git] / apps / plugins / test_greylib_bitmap_scale.c
blob892f3dc622ca09292781cc1705baa1e08c742b04
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_bmp.h"
26 #if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
27 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
28 #define GBS_QUIT BUTTON_MENU
29 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
30 #define GBS_QUIT BUTTON_RC_REC
31 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
32 #define GBS_QUIT BUTTON_PLAY
33 #elif CONFIG_KEYPAD == MPIO_HD200_PAD
34 #define GBS_QUIT (BUTTON_REC|BUTTON_PLAY)
35 #elif defined(BUTTON_OFF)
36 #define GBS_QUIT BUTTON_OFF
37 #else
38 #define GBS_QUIT BUTTON_POWER
39 #endif
41 #if LCD_DEPTH == 1
42 #define BMP_LOAD read_bmp_file
43 #else
44 #define BMP_LOAD rb->read_bmp_file
45 #endif
47 PLUGIN_HEADER
48 GREY_INFO_STRUCT
49 static unsigned char grey_bm_buf[LCD_WIDTH * LCD_HEIGHT +
50 BM_SCALED_SIZE(LCD_WIDTH,0,FORMAT_NATIVE,0)];
52 /* this is the plugin entry point */
53 enum plugin_status plugin_start(const void* parameter)
55 void * plugin_buf;
56 size_t plugin_buf_len;
57 static char filename[MAX_PATH];
58 struct bitmap grey_bm = {
59 .width = LCD_WIDTH,
60 .height = LCD_HEIGHT,
61 .data = grey_bm_buf
63 int ret, x, y;
65 if(!parameter) return PLUGIN_ERROR;
67 rb->strcpy(filename, parameter);
69 ret = BMP_LOAD(filename, &grey_bm, sizeof(grey_bm_buf),
70 FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_KEEP_ASPECT,
71 &format_grey);
73 if(ret < 1)
75 rb->splash(HZ*2, "failed to load bitmap");
76 return PLUGIN_ERROR;
79 plugin_buf = rb->plugin_get_buffer(&plugin_buf_len);
80 if(!grey_init(plugin_buf, plugin_buf_len, 0, LCD_WIDTH, LCD_HEIGHT,
81 NULL))
83 rb->splash(HZ*2,"grey init failed");
84 return PLUGIN_ERROR;
86 grey_ub_clear_display();
87 x = (LCD_WIDTH - grey_bm.width) / 2;
88 y = (LCD_HEIGHT - grey_bm.height) / 2;
89 grey_ub_gray_bitmap(grey_bm_buf, x, y, grey_bm.width, grey_bm.height);
90 grey_show(true);
92 /* wait until user closes plugin */
93 while (rb->button_get(true) != GBS_QUIT);
95 grey_release();
97 return PLUGIN_OK;