static int read_ppm_row(int fd, struct ppm_info *ppm, int row) { int col; int r, g, b; #ifdef HAVE_LCD_COLOR #if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE fb_data *dst = (fb_data *) ppm->buf + row; const int stride = ppm->x; #else fb_data *dst = (fb_data *) ppm->buf + ppm->x*row; const int stride = 1; #endif #endif /* HAVE_LCD_COLOR */ switch (ppm->format) { case PPM_FORMAT: for (col = 0; col < ppm->x; ++col) { r = ppm_getuint(fd); g = ppm_getuint(fd); b = ppm_getuint(fd); if (r == PLUGIN_ERROR || g == PLUGIN_ERROR || b == PLUGIN_ERROR) { return PLUGIN_ERROR; } *dst = FB_RGBPACK( (255 * r)/ppm->maxval, (255 * g)/ppm->maxval, (255 * b)/ppm->maxval); dst += stride; } break; case RPPM_FORMAT: for (col = 0; col < ppm->x; ++col) { r = ppm_getrawsample(fd, ppm->maxval); g = ppm_getrawsample(fd, ppm->maxval); b = ppm_getrawsample(fd, ppm->maxval); if (r == PLUGIN_ERROR || g == PLUGIN_ERROR || b == PLUGIN_ERROR) { return PLUGIN_ERROR; } *dst = FB_RGBPACK( (255 * r)/ppm->maxval, (255 * g)/ppm->maxval, (255 * b)/ppm->maxval); dst += stride; } break; default: ppm_error("What?!"); return PLUGIN_ERROR; } return PLUGIN_OK; }
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) { case PPM_FORMAT: for (col = 0; col < cols; ++col) { r = ppm_getuint(fd); g = ppm_getuint(fd); b = ppm_getuint(fd); if (r == PLUGIN_ERROR || g == PLUGIN_ERROR || b == PLUGIN_ERROR) { return PLUGIN_ERROR; } *BUFADDR(col, row, cols, rows) = LCD_RGBPACK( (255 / maxval) * r, (255 / maxval) * g, (255 / maxval) * b); } break; case RPPM_FORMAT: for (col = 0; col < cols; ++col) { r = ppm_getrawsample(fd, maxval); g = ppm_getrawsample(fd, maxval); b = ppm_getrawsample(fd, maxval); if (r == PLUGIN_ERROR || g == PLUGIN_ERROR || b == PLUGIN_ERROR) { return PLUGIN_ERROR; } *BUFADDR(col, row, cols, rows) = LCD_RGBPACK( (255 / maxval) * r, (255 / maxval) * g, (255 / maxval) * b); } break; default: ppm_error("What?!"); return PLUGIN_ERROR; } return 1; }