summaryrefslogtreecommitdiffstats
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,
}
}
+#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;
}
}