From 658d9ff87eb93b7b8fa84d7453d591814b4c9fa4 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 8 Jul 2010 20:16:47 +0000 Subject: Pre-seed remainder counters with correct starting value to avoid clipping edge case artifact. svn path=/trunk/libnsfb/; revision=10615 --- src/plot/16bpp.c | 26 +++++++++++++++++++------- src/plot/32bpp.c | 26 +++++++++++++++++++------- src/plot/8bpp.c | 26 +++++++++++++++++++------- 3 files changed, 57 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/plot/16bpp.c b/src/plot/16bpp.c index 028e453..ee95770 100644 --- a/src/plot/16bpp.c +++ b/src/plot/16bpp.c @@ -339,7 +339,7 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc, int rheight, rwidth; /* post-clipping render area dimensions */ int dx, dy; /* scale factor (integer part) */ int dxr, dyr; /* scale factor (remainder) */ - int rx, ry; /* remainder trackers */ + int rx, ry, rxs; /* remainder trackers */ nsfb_bbox_t clipped; /* clipped display */ /* The part of the scaled image actually displayed is cropped to the @@ -365,17 +365,29 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc, else rwidth = width; - /* start offsets to part of image being scaled, after clipping */ - xoffs = ((clipped.x0 - x) * bmp_width) / width; - yoff = (((clipped.y0 - y) * bmp_height) / height) * bmp_stride; - /* get veritcal (y) and horizontal (x) scale factors; both integer * part and remainder */ dx = bmp_width / width; dy = (bmp_height / height) * bmp_stride; dxr = bmp_width % width; dyr = bmp_height % height; - rx = ry = 0; /* initialise remainder counters */ + + /* get start offsets to part of image being scaled, after clipping and + * set remainder trackers to correct starting */ + if (clipped.x0 - x != 0) { + xoffs = ((clipped.x0 - x) * bmp_width) / width; + rxs = ((clipped.x0 - x) * bmp_width) % width; + } else { + xoffs = 0; + rxs = 0; + } + if (clipped.y0 - y != 0) { + yoff = (((clipped.y0 - y) * bmp_height) / height) * bmp_stride; + ry = ((clipped.y0 - y) * bmp_height) % height; + } else { + yoff = 0; + ry = 0; + } /* plot the image */ pvideo = get_xy_loc(nsfb, clipped.x0, clipped.y0); @@ -384,7 +396,7 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc, for (; pvideo < pvideo_limit; pvideo += (nsfb->linelen >> 1)) { /* looping through render area vertically */ xoff = xoffs; - rx = 0; + rx = rxs; for (xloop = 0; xloop < rwidth; xloop++) { /* looping through render area horizontally */ /* get value of source pixel in question */ diff --git a/src/plot/32bpp.c b/src/plot/32bpp.c index 434baa6..96fadbd 100644 --- a/src/plot/32bpp.c +++ b/src/plot/32bpp.c @@ -337,7 +337,7 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc, int rheight, rwidth; /* post-clipping render area dimensions */ int dx, dy; /* scale factor (integer part) */ int dxr, dyr; /* scale factor (remainder) */ - int rx, ry; /* remainder trackers */ + int rx, ry, rxs; /* remainder trackers */ nsfb_bbox_t clipped; /* clipped display */ /* The part of the scaled image actually displayed is cropped to the @@ -363,17 +363,29 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc, else rwidth = width; - /* start offsets to part of image being scaled, after clipping */ - xoffs = ((clipped.x0 - x) * bmp_width) / width; - yoff = (((clipped.y0 - y) * bmp_height) / height) * bmp_stride; - /* get veritcal (y) and horizontal (x) scale factors; both integer * part and remainder */ dx = bmp_width / width; dy = (bmp_height / height) * bmp_stride; dxr = bmp_width % width; dyr = bmp_height % height; - rx = ry = 0; /* initialise remainder counters */ + + /* get start offsets to part of image being scaled, after clipping and + * set remainder trackers to correct starting */ + if (clipped.x0 - x != 0) { + xoffs = ((clipped.x0 - x) * bmp_width) / width; + rxs = ((clipped.x0 - x) * bmp_width) % width; + } else { + xoffs = 0; + rxs = 0; + } + if (clipped.y0 - y != 0) { + yoff = (((clipped.y0 - y) * bmp_height) / height) * bmp_stride; + ry = ((clipped.y0 - y) * bmp_height) % height; + } else { + yoff = 0; + ry = 0; + } /* plot the image */ pvideo = get_xy_loc(nsfb, clipped.x0, clipped.y0); @@ -382,7 +394,7 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc, for (; pvideo < pvideo_limit; pvideo += (nsfb->linelen >> 2)) { /* looping through render area vertically */ xoff = xoffs; - rx = 0; + rx = rxs; for (xloop = 0; xloop < rwidth; xloop++) { /* looping through render area horizontally */ /* get value of source pixel in question */ diff --git a/src/plot/8bpp.c b/src/plot/8bpp.c index 472c213..d1d43ee 100644 --- a/src/plot/8bpp.c +++ b/src/plot/8bpp.c @@ -316,7 +316,7 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc, int rheight, rwidth; /* post-clipping render area dimensions */ int dx, dy; /* scale factor (integer part) */ int dxr, dyr; /* scale factor (remainder) */ - int rx, ry; /* remainder trackers */ + int rx, ry, rxs; /* remainder trackers */ nsfb_bbox_t clipped; /* clipped display */ /* The part of the scaled image actually displayed is cropped to the @@ -342,17 +342,29 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc, else rwidth = width; - /* start offsets to part of image being scaled, after clipping */ - xoffs = ((clipped.x0 - x) * bmp_width) / width; - yoff = (((clipped.y0 - y) * bmp_height) / height) * bmp_stride; - /* get veritcal (y) and horizontal (x) scale factors; both integer * part and remainder */ dx = bmp_width / width; dy = (bmp_height / height) * bmp_stride; dxr = bmp_width % width; dyr = bmp_height % height; - rx = ry = 0; /* initialise remainder counters */ + + /* get start offsets to part of image being scaled, after clipping and + * set remainder trackers to correct starting */ + if (clipped.x0 - x != 0) { + xoffs = ((clipped.x0 - x) * bmp_width) / width; + rxs = ((clipped.x0 - x) * bmp_width) % width; + } else { + xoffs = 0; + rxs = 0; + } + if (clipped.y0 - y != 0) { + yoff = (((clipped.y0 - y) * bmp_height) / height) * bmp_stride; + ry = ((clipped.y0 - y) * bmp_height) % height; + } else { + yoff = 0; + ry = 0; + } /* plot the image */ pvideo = get_xy_loc(nsfb, clipped.x0, clipped.y0); @@ -361,7 +373,7 @@ static bool bitmap_scaled(nsfb_t *nsfb, const nsfb_bbox_t *loc, for (; pvideo < pvideo_limit; pvideo += (nsfb->linelen)) { /* looping through render area vertically */ xoff = xoffs; - rx = 0; + rx = rxs; for (xloop = 0; xloop < rwidth; xloop++) { /* looping through render area horizontally */ /* get value of source pixel in question */ -- cgit v1.2.3