1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 Jonas Hurrelmann
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 /* Resizing test plugin. Loads /test.bmp (max 100x100) and displays a resized
21 * version. Use the scrollwheel or the left/right keys to change the size of
22 * the resizded version.
26 #include "pluginlib_actions.h"
31 static struct plugin_api
* rb
;
33 const struct button_mapping
*plugin_contexts
[]
34 = {generic_actions
, generic_directions
};
36 #define NB_ACTION_CONTEXTS sizeof(plugin_contexts)/sizeof(plugin_contexts[0])
39 #if (CONFIG_KEYPAD == IPOD_1G2G_PAD) \
40 || (CONFIG_KEYPAD == IPOD_3G_PAD) \
41 || (CONFIG_KEYPAD == IPOD_4G_PAD) \
42 || (CONFIG_KEYPAD == SANSA_E200_PAD)
43 #define SIZE_INCREASE PLA_UP
44 #define SIZE_INCREASE_REPEAT PLA_UP_REPEAT
45 #define SIZE_DECREASE PLA_DOWN
46 #define SIZE_DECREASE_REPEAT PLA_DOWN_REPEAT
48 #define SIZE_INCREASE PLA_RIGHT
49 #define SIZE_INCREASE_REPEAT PLA_RIGHT_REPEAT
50 #define SIZE_DECREASE PLA_LEFT
51 #define SIZE_DECREASE_REPEAT PLA_LEFT_REPEAT
53 #define BUTTON_QUIT PLA_QUIT
55 #define MAX_OUTPUT_WIDTH 200
56 #define MAX_OUTPUT_HEIGHT 200
60 static struct bitmap input_bmp
;
61 static struct bitmap output_bmp
;
63 static fb_data input_bmp_data
[100*100];
64 static fb_data output_bmp_data
[MAX_OUTPUT_WIDTH
*MAX_OUTPUT_HEIGHT
];
67 /* this is the plugin entry point */
68 enum plugin_status
plugin_start(struct plugin_api
* api
, void* parameter
)
73 b
= rb
->lcd_framebuffer
;
75 rb
->lcd_set_background(LCD_RGBPACK(0,0,0));
76 rb
->lcd_clear_display(); // TODO: Optimizes this by e.g. invalidating rects
78 input_bmp
.data
= (char*)input_bmp_data
;
79 output_bmp
.data
= (char*)output_bmp_data
;
81 int ret
= rb
->read_bmp_file("/test.bmp", &input_bmp
, sizeof(input_bmp_data
),
85 rb
->splash(HZ
, "Could not load /test.bmp");
90 output_bmp
.width
= 50;
91 output_bmp
.height
= 50;
93 DEBUGF("input_bmp_data starts at %p\n", input_bmp_data
);
94 DEBUGF("output_bmp_data starts at %p\n", output_bmp_data
);
97 rb
->lcd_clear_display();
98 rb
->lcd_bitmap(input_bmp_data
, 0, 0, input_bmp
.width
, input_bmp
.height
);
100 simple_resize_bitmap(&input_bmp
, &output_bmp
);
102 rb
->lcd_bitmap(output_bmp_data
, 0, 100, output_bmp
.width
,
106 button
= pluginlib_getaction(rb
, HZ
,
107 plugin_contexts
, NB_ACTION_CONTEXTS
);
112 case SIZE_INCREASE_REPEAT
:
113 if (output_bmp
.width
< MAX_OUTPUT_WIDTH
- 2)
114 output_bmp
.width
+= 2;
115 if (output_bmp
.height
< MAX_OUTPUT_HEIGHT
- 2)
116 output_bmp
.height
+= 2;
120 case SIZE_DECREASE_REPEAT
:
121 if (output_bmp
.width
>= 2) output_bmp
.width
-= 2;
122 if (output_bmp
.height
>= 2) output_bmp
.height
-= 2;