From 5a435e62d062c7bc75c27a324e89de06cc4543f9 Mon Sep 17 00:00:00 2001 From: Karl Kurbjun Date: Thu, 8 Oct 2009 04:52:44 +0000 Subject: PPM viewer - initial support for vertical strides - scaler needs to be modified for full support. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23006 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/ppmviewer.c | 17 ++++++++++++++--- 1 file 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, } } +#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#define BUFADDR(x, y, width, height) ( buffer + height*(x) + (y)) +#else +#define BUFADDR(x, y, width, height) ( buffer + width*(y) + (x)) +#endif + int read_ppm_row(int fd, int const row, int const cols, + int const rows, int const maxval, int const format) { +#if !(defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE) + (void) rows; +#endif + int col; int r, g, b; switch (format) { @@ -213,7 +224,7 @@ int read_ppm_row(int fd, { return PLUGIN_ERROR; } - buffer[(cols * row) + col] = LCD_RGBPACK( + *BUFADDR(col, row, cols, rows) = LCD_RGBPACK( (255 / maxval) * r, (255 / maxval) * g, (255 / maxval) * b); @@ -231,7 +242,7 @@ int read_ppm_row(int fd, { return PLUGIN_ERROR; } - buffer[(cols * row) + col] = LCD_RGBPACK( + *BUFADDR(col, row, cols, rows) = LCD_RGBPACK( (255 / maxval) * r, (255 / maxval) * g, (255 / maxval) * b); @@ -260,7 +271,7 @@ int read_ppm(int fd, } for (row = 0; row < *rows; ++row) { - if( read_ppm_row(fd, row, *cols, *maxval, format) == PLUGIN_ERROR) { + if( read_ppm_row(fd, row, *cols, *rows, *maxval, format) == PLUGIN_ERROR) { return PLUGIN_ERROR; } } -- cgit v1.2.3