summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Mahone <andrew.mahone@gmail.com>2008-12-26 10:25:17 +0000
committerAndrew Mahone <andrew.mahone@gmail.com>2008-12-26 10:25:17 +0000
commit859ee227ba1d11e3a5080922b322adcc3973e892 (patch)
tree91063f24339e765faf64c2d82f4ffc64eea551b5
parent0f472bcd1961e193ff8bd0564d8322bc0d212915 (diff)
downloadrockbox-859ee227ba1d11e3a5080922b322adcc3973e892.tar.gz
rockbox-859ee227ba1d11e3a5080922b322adcc3973e892.zip
Add missing greylib scaled bitmap test plugin.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19595 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/test_greylib_bitmap_scale.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/apps/plugins/test_greylib_bitmap_scale.c b/apps/plugins/test_greylib_bitmap_scale.c
new file mode 100644
index 0000000000..f8a7bb92cc
--- /dev/null
+++ b/apps/plugins/test_greylib_bitmap_scale.c
@@ -0,0 +1,78 @@
1/*****************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// __ \_/ ___\| |/ /| __ \ / __ \ \/ /
5 * Jukebox | | ( (__) ) \___| ( | \_\ ( (__) ) (
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Andrew Mahone
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "plugin.h"
23#include "lib/grey.h"
24
25PLUGIN_HEADER
26GREY_INFO_STRUCT
27static unsigned char grey_bm_buf[LCD_WIDTH * LCD_HEIGHT +
28 BM_SCALED_SIZE(LCD_WIDTH,0,FORMAT_NATIVE,0)];
29static unsigned char grey_display_buf[2*LCD_WIDTH * LCD_HEIGHT];
30
31static const struct plugin_api* rb; /* global api struct pointer */
32
33/* this is the plugin entry point */
34enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
35{
36 static char filename[MAX_PATH];
37 struct bitmap grey_bm = {
38 .width = LCD_WIDTH,
39 .height = LCD_HEIGHT,
40 .data = grey_bm_buf
41 };
42 int ret, x, y;
43
44 if(!parameter) return PLUGIN_ERROR;
45
46 rb = api;
47
48 rb->strcpy(filename, parameter);
49
50 ret = rb->read_bmp_file(filename, &grey_bm, sizeof(grey_bm_buf),
51 FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_KEEP_ASPECT,
52 &format_grey);
53
54 if(ret < 1)
55 {
56 rb->splash(HZ*2, "failed to load bitmap");
57 return PLUGIN_ERROR;
58 }
59
60 long buf_taken;
61 if(!grey_init(rb, &grey_display_buf[0], sizeof(grey_display_buf), 0,
62 LCD_WIDTH, LCD_HEIGHT, &buf_taken))
63 {
64 rb->splash(HZ*2,"grey init failed");
65 return PLUGIN_ERROR;
66 }
67 grey_ub_clear_display();
68 x = (LCD_WIDTH - grey_bm.width) / 2;
69 y = (LCD_HEIGHT - grey_bm.height) / 2;
70 grey_ub_gray_bitmap(grey_bm_buf, x, y, grey_bm.width, grey_bm.height);
71 grey_show(true);
72
73 rb->button_get(true);
74
75 grey_release();
76
77 return PLUGIN_OK;
78}