diff options
Diffstat (limited to 'src/plot/32bpp.c')
-rw-r--r-- | src/plot/32bpp.c | 26 |
1 files changed, 19 insertions, 7 deletions
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 */ |