summaryrefslogtreecommitdiff
path: root/apps/plugins/test_resize.c
diff options
context:
space:
mode:
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[]
36#define NB_ACTION_CONTEXTS sizeof(plugin_contexts)/sizeof(plugin_contexts[0]) 36#define NB_ACTION_CONTEXTS sizeof(plugin_contexts)/sizeof(plugin_contexts[0])
37 37
38/* Key assignement */ 38/* Key assignement */
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 39#define SIZE_INCREASE PLA_UP
44#define SIZE_INCREASE_REPEAT PLA_UP_REPEAT 40#define SIZE_INCREASE_REPEAT PLA_UP_REPEAT
45#define SIZE_DECREASE PLA_DOWN 41#define SIZE_DECREASE PLA_DOWN
46#define SIZE_DECREASE_REPEAT PLA_DOWN_REPEAT 42#define SIZE_DECREASE_REPEAT PLA_DOWN_REPEAT
47#else 43
48#define SIZE_INCREASE PLA_RIGHT 44#define WIDTH_INCREASE PLA_RIGHT
49#define SIZE_INCREASE_REPEAT PLA_RIGHT_REPEAT 45#define WIDTH_INCREASE_REPEAT PLA_RIGHT_REPEAT
50#define SIZE_DECREASE PLA_LEFT 46#define WIDTH_DECREASE PLA_LEFT
51#define SIZE_DECREASE_REPEAT PLA_LEFT_REPEAT 47#define WIDTH_DECREASE_REPEAT PLA_LEFT_REPEAT
52#endif 48
53#define BUTTON_QUIT PLA_QUIT 49#define BUTTON_QUIT PLA_QUIT
50#define CHANGE_MODE PLA_MENU
54 51
55#define MAX_OUTPUT_WIDTH 200 52#define MAX_OUTPUT_WIDTH LCD_WIDTH
56#define MAX_OUTPUT_HEIGHT 200 53#define MAX_OUTPUT_HEIGHT LCD_HEIGHT
57 54
58static fb_data *b; 55static fb_data *b;
59 56
60static struct bitmap input_bmp; 57static struct bitmap input_bmp;
61static struct bitmap output_bmp; 58static struct bitmap output_bmp;
62 59
63static fb_data input_bmp_data[100*100]; 60static fb_data input_bmp_data[200*200];
64static fb_data output_bmp_data[MAX_OUTPUT_WIDTH*MAX_OUTPUT_HEIGHT]; 61static fb_data output_bmp_data[MAX_OUTPUT_WIDTH*MAX_OUTPUT_HEIGHT];
65 62
66 63
@@ -93,11 +90,22 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
93 DEBUGF("input_bmp_data starts at %p\n", input_bmp_data); 90 DEBUGF("input_bmp_data starts at %p\n", input_bmp_data);
94 DEBUGF("output_bmp_data starts at %p\n", output_bmp_data); 91 DEBUGF("output_bmp_data starts at %p\n", output_bmp_data);
95 92
93 int scale_algorithm = 0;
94
96 while(1) { 95 while(1) {
97 rb->lcd_clear_display(); 96 rb->lcd_clear_display();
98 rb->lcd_bitmap(input_bmp_data, 0, 0, input_bmp.width, input_bmp.height); 97 rb->lcd_bitmap(input_bmp_data, 0, 0, input_bmp.width, input_bmp.height);
99 98
100 simple_resize_bitmap(&input_bmp, &output_bmp); 99 switch ( scale_algorithm ) {
100 case 0:
101 smooth_resize_bitmap(&input_bmp, &output_bmp);
102 rb->lcd_putsxy(0,0,"smooth_resize_bitmap");
103 break;
104 case 1:
105 simple_resize_bitmap(&input_bmp, &output_bmp);
106 rb->lcd_putsxy(0,0,"simple_resize_bitmap");
107 break;
108 }
101 109
102 rb->lcd_bitmap(output_bmp_data, 0, 100, output_bmp.width, 110 rb->lcd_bitmap(output_bmp_data, 0, 100, output_bmp.width,
103 output_bmp.height); 111 output_bmp.height);
@@ -118,8 +126,23 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
118 126
119 case SIZE_DECREASE: 127 case SIZE_DECREASE:
120 case SIZE_DECREASE_REPEAT: 128 case SIZE_DECREASE_REPEAT:
121 if (output_bmp.width >= 2) output_bmp.width -= 2; 129 if (output_bmp.width > 2) output_bmp.width -= 2;
122 if (output_bmp.height >= 2) output_bmp.height -= 2; 130 if (output_bmp.height > 2) output_bmp.height -= 2;
131 break;
132
133 case WIDTH_INCREASE:
134 case WIDTH_INCREASE_REPEAT:
135 if (output_bmp.width < MAX_OUTPUT_WIDTH - 2)
136 output_bmp.width += 2;
137 break;
138
139 case WIDTH_DECREASE:
140 case WIDTH_DECREASE_REPEAT:
141 if (output_bmp.width > 2) output_bmp.width -= 2;
142 break;
143
144 case CHANGE_MODE:
145 scale_algorithm = (scale_algorithm+1)%2;
123 break; 146 break;
124 } 147 }
125 } 148 }