summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/ppmviewer.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/apps/plugins/ppmviewer.c b/apps/plugins/ppmviewer.c
index 56193b3c47..cc7440de96 100644
--- a/apps/plugins/ppmviewer.c
+++ b/apps/plugins/ppmviewer.c
@@ -193,12 +193,23 @@ void read_ppm_init(int fd,
193 } 193 }
194} 194}
195 195
196#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE
197#define BUFADDR(x, y, width, height) ( buffer + height*(x) + (y))
198#else
199#define BUFADDR(x, y, width, height) ( buffer + width*(y) + (x))
200#endif
201
196int read_ppm_row(int fd, 202int read_ppm_row(int fd,
197 int const row, 203 int const row,
198 int const cols, 204 int const cols,
205 int const rows,
199 int const maxval, 206 int const maxval,
200 int const format) 207 int const format)
201{ 208{
209#if !(defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE)
210 (void) rows;
211#endif
212
202 int col; 213 int col;
203 int r, g, b; 214 int r, g, b;
204 switch (format) { 215 switch (format) {
@@ -213,7 +224,7 @@ int read_ppm_row(int fd,
213 { 224 {
214 return PLUGIN_ERROR; 225 return PLUGIN_ERROR;
215 } 226 }
216 buffer[(cols * row) + col] = LCD_RGBPACK( 227 *BUFADDR(col, row, cols, rows) = LCD_RGBPACK(
217 (255 / maxval) * r, 228 (255 / maxval) * r,
218 (255 / maxval) * g, 229 (255 / maxval) * g,
219 (255 / maxval) * b); 230 (255 / maxval) * b);
@@ -231,7 +242,7 @@ int read_ppm_row(int fd,
231 { 242 {
232 return PLUGIN_ERROR; 243 return PLUGIN_ERROR;
233 } 244 }
234 buffer[(cols * row) + col] = LCD_RGBPACK( 245 *BUFADDR(col, row, cols, rows) = LCD_RGBPACK(
235 (255 / maxval) * r, 246 (255 / maxval) * r,
236 (255 / maxval) * g, 247 (255 / maxval) * g,
237 (255 / maxval) * b); 248 (255 / maxval) * b);
@@ -260,7 +271,7 @@ int read_ppm(int fd,
260 } 271 }
261 272
262 for (row = 0; row < *rows; ++row) { 273 for (row = 0; row < *rows; ++row) {
263 if( read_ppm_row(fd, row, *cols, *maxval, format) == PLUGIN_ERROR) { 274 if( read_ppm_row(fd, row, *cols, *rows, *maxval, format) == PLUGIN_ERROR) {
264 return PLUGIN_ERROR; 275 return PLUGIN_ERROR;
265 } 276 }
266 } 277 }