fix broken greyscale upscaling

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19393 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Andrew Mahone 2008-12-12 02:44:13 +00:00
parent ea5457ca90
commit 66b0d8198e

View file

@ -456,7 +456,7 @@ static inline bool scale_nearest(struct bitmap *bm,
const int fb_width = get_fb_width(bm, false); const int fb_width = get_fb_width(bm, false);
long last_tick = current_tick; long last_tick = current_tick;
int ix, ox, lx, xe, iy, oy, ly, ye, yet, oyt; int ix, ox, lx, xe, iy, oy, ly, ye, yet, oyt;
int ixls, xels, iyls, yelsi, oyls, yelso, p; int xelim, ixls, xels, yelim, iyls, yels, oyls, p;
struct img_part *cur_part; struct img_part *cur_part;
#ifndef HAVE_LCD_COLOR #ifndef HAVE_LCD_COLOR
fb_data *dest = dest, *dest_t; fb_data *dest = dest, *dest_t;
@ -470,12 +470,12 @@ static inline bool scale_nearest(struct bitmap *bm,
ly = 0; ly = 0;
iy = 0; iy = 0;
ye = 0; ye = 0;
ixls = (sw > (dw - 1) && dw > 1) ? sw / (dw - 1) : 1; xelim = sw == dw - 1 ? dw : dw - 1;
xels = sw - ixls * (dw - 1) + (dw == 1 ? 1 : 0); ixls = xelim ? sw / xelim : 1;
iyls = (sh > (dh - 1) && dh > 1) ? sh / (dh - 1) : 1; xels = sw - ixls * (xelim ? xelim : 1);
oyls = dh > sh ? dh / sh : 1; yelim = sh == dh - 1 ? dh : dh - 1;
yelsi = iyls * (dh - 1) + (dh == 1 ? 1 : 0); iyls = yelim ? sh / yelim : 1;
yelso = oyls * sh; yels = iyls * (yelim ? yelim : 1);
oyls *= rowstep; oyls *= rowstep;
int delta = 127; int delta = 127;
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING || \ #if LCD_PIXELFORMAT == HORIZONTAL_PACKING || \
@ -563,7 +563,7 @@ static inline bool scale_nearest(struct bitmap *bm,
*dest_t = data; *dest_t = data;
dest_t += rowstep * fb_width; dest_t += rowstep * fb_width;
yet += sh; yet += sh;
oyt += 1; oyt += rowstep;
} }
} }
#elif LCD_PIXELFORMAT == VERTICAL_PACKING #elif LCD_PIXELFORMAT == VERTICAL_PACKING
@ -583,7 +583,7 @@ static inline bool scale_nearest(struct bitmap *bm,
if ((rowstep > 0 && shift == 6) || shift == 0) if ((rowstep > 0 && shift == 6) || shift == 0)
dest_t += rowstep * fb_width; dest_t += rowstep * fb_width;
yet += sh; yet += sh;
oyt += 1; oyt += rowstep;
} }
#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED #elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
bright = brightness(*(cur_part->buf)); bright = brightness(*(cur_part->buf));
@ -601,7 +601,7 @@ static inline bool scale_nearest(struct bitmap *bm,
if ((rowstep > 0 && shift == 7) || shift == 0) if ((rowstep > 0 && shift == 7) || shift == 0)
dest_t += rowstep * fb_width; dest_t += rowstep * fb_width;
yet += sh; yet += sh;
oyt += 1; oyt += rowstep;
} }
#endif /* LCD_PIXELFORMAT */ #endif /* LCD_PIXELFORMAT */
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
@ -625,7 +625,7 @@ static inline bool scale_nearest(struct bitmap *bm,
if ((rowstep > 0 && shift == 7) || shift == 0) if ((rowstep > 0 && shift == 7) || shift == 0)
rdest_t += rowstep * fb_width; rdest_t += rowstep * fb_width;
yet += sh; yet += sh;
oyt += 1; oyt += rowstep;
} }
#else #else
bright = brightness(*(cur_part->buf)); bright = brightness(*(cur_part->buf));
@ -642,31 +642,25 @@ static inline bool scale_nearest(struct bitmap *bm,
if ((rowstep > 0 && shift == 7) || shift == 0) if ((rowstep > 0 && shift == 7) || shift == 0)
rdest_t += rowstep * fb_width; rdest_t += rowstep * fb_width;
yet += sh; yet += sh;
oyt += 1; oyt += rowstep;
} }
#endif #endif
} }
#endif #endif
xe += xels; xe += xels;
ix += ixls; ix += ixls;
while (xe >= dw) while (xe > xelim)
{ {
xe -= dw - 1; xe -= xelim;
ix += 1; ix += 1;
} }
} }
oy += oyls; oy = oyt;
ye += yelso; ye = yet - yels;
while (ye < dh)
{
ye += sh;
oy += rowstep;
}
iy += iyls; iy += iyls;
ye -= yelsi; while (ye > yelim)
while (ye >= dh)
{ {
ye -= dh - 1; ye -= yelim;
iy += 1; iy += 1;
} }
} }