summaryrefslogtreecommitdiffstats
path: root/apps/plugins/test_resize.c
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2008-04-06 22:30:50 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2008-04-06 22:30:50 +0000
commit6aa36c66a356f72efe9b23e895b19acb8e825943 (patch)
tree1e036e2967d1ae38be5c99d748018937cecfee16 /apps/plugins/test_resize.c
parent9ba80c9641e19b421d5c7544d081a2d458c509b1 (diff)
downloadrockbox-6aa36c66a356f72efe9b23e895b19acb8e825943.tar.gz
rockbox-6aa36c66a356f72efe9b23e895b19acb8e825943.zip
Commit FS#8308 (Port of imlib2 based smooth scaling) by Jonas Hurrelmann. It could be made smaller by taking out some special cases, but I'm leaving them in for now because size isn't really a concern until we decide to move it into the core (if we ever do). test_resize now allows to choose between both resize methods for comparison. sliding_puzzle is made to use the smooth scaling.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17001 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/test_resize.c')
-rw-r--r--apps/plugins/test_resize.c55
1 files changed, 39 insertions, 16 deletions
diff --git a/apps/plugins/test_resize.c b/apps/plugins/test_resize.c
index 8583613d99..c50bc5f91c 100644
--- a/apps/plugins/test_resize.c
+++ b/apps/plugins/test_resize.c
@@ -36,31 +36,28 @@ const struct button_mapping *plugin_contexts[]
#define NB_ACTION_CONTEXTS sizeof(plugin_contexts)/sizeof(plugin_contexts[0])
/* Key assignement */
-#if (CONFIG_KEYPAD == IPOD_1G2G_PAD) \
- || (CONFIG_KEYPAD == IPOD_3G_PAD) \
- || (CONFIG_KEYPAD == IPOD_4G_PAD) \
- || (CONFIG_KEYPAD == SANSA_E200_PAD)
#define SIZE_INCREASE PLA_UP
#define SIZE_INCREASE_REPEAT PLA_UP_REPEAT
#define SIZE_DECREASE PLA_DOWN
#define SIZE_DECREASE_REPEAT PLA_DOWN_REPEAT
-#else
-#define SIZE_INCREASE PLA_RIGHT
-#define SIZE_INCREASE_REPEAT PLA_RIGHT_REPEAT
-#define SIZE_DECREASE PLA_LEFT
-#define SIZE_DECREASE_REPEAT PLA_LEFT_REPEAT
-#endif
+
+#define WIDTH_INCREASE PLA_RIGHT
+#define WIDTH_INCREASE_REPEAT PLA_RIGHT_REPEAT
+#define WIDTH_DECREASE PLA_LEFT
+#define WIDTH_DECREASE_REPEAT PLA_LEFT_REPEAT
+
#define BUTTON_QUIT PLA_QUIT
+#define CHANGE_MODE PLA_MENU
-#define MAX_OUTPUT_WIDTH 200
-#define MAX_OUTPUT_HEIGHT 200
+#define MAX_OUTPUT_WIDTH LCD_WIDTH
+#define MAX_OUTPUT_HEIGHT LCD_HEIGHT
static fb_data *b;
static struct bitmap input_bmp;
static struct bitmap output_bmp;
-static fb_data input_bmp_data[100*100];
+static fb_data input_bmp_data[200*200];
static fb_data output_bmp_data[MAX_OUTPUT_WIDTH*MAX_OUTPUT_HEIGHT];
@@ -93,11 +90,22 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
DEBUGF("input_bmp_data starts at %p\n", input_bmp_data);
DEBUGF("output_bmp_data starts at %p\n", output_bmp_data);
+ int scale_algorithm = 0;
+
while(1) {
rb->lcd_clear_display();
rb->lcd_bitmap(input_bmp_data, 0, 0, input_bmp.width, input_bmp.height);
- simple_resize_bitmap(&input_bmp, &output_bmp);
+ switch ( scale_algorithm ) {
+ case 0:
+ smooth_resize_bitmap(&input_bmp, &output_bmp);
+ rb->lcd_putsxy(0,0,"smooth_resize_bitmap");
+ break;
+ case 1:
+ simple_resize_bitmap(&input_bmp, &output_bmp);
+ rb->lcd_putsxy(0,0,"simple_resize_bitmap");
+ break;
+ }
rb->lcd_bitmap(output_bmp_data, 0, 100, output_bmp.width,
output_bmp.height);
@@ -118,8 +126,23 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
case SIZE_DECREASE:
case SIZE_DECREASE_REPEAT:
- if (output_bmp.width >= 2) output_bmp.width -= 2;
- if (output_bmp.height >= 2) output_bmp.height -= 2;
+ if (output_bmp.width > 2) output_bmp.width -= 2;
+ if (output_bmp.height > 2) output_bmp.height -= 2;
+ break;
+
+ case WIDTH_INCREASE:
+ case WIDTH_INCREASE_REPEAT:
+ if (output_bmp.width < MAX_OUTPUT_WIDTH - 2)
+ output_bmp.width += 2;
+ break;
+
+ case WIDTH_DECREASE:
+ case WIDTH_DECREASE_REPEAT:
+ if (output_bmp.width > 2) output_bmp.width -= 2;
+ break;
+
+ case CHANGE_MODE:
+ scale_algorithm = (scale_algorithm+1)%2;
break;
}
}