Permalink
Browse files

draw_image can now draw images with x<0, fixes #433

this isn't used at all in the source
  • Loading branch information...
jacob1 committed Jun 12, 2017
1 parent 0ea5c1d commit d4a0ff9ac8e6293de9f33dde393eaa46e1b78396
Showing with 33 additions and 9 deletions.
  1. +33 −9 src/graphics/RasterDrawMethods.inl
@@ -445,33 +445,57 @@ void PIXELMETHODS_CLASS::clearrect(int x, int y, int w, int h)
void PIXELMETHODS_CLASS::draw_image(pixel *img, int x, int y, int w, int h, int a)
{
int i, j, r, g, b;
if (!img) return;
if(y + h > VIDYRES) h = ((VIDYRES)-y)-1; //Adjust height to prevent drawing off the bottom
int startX = 0;
if (!img)
return;
// Adjust height to prevent drawing off the bottom
if (y + h > VIDYRES)
h = ((VIDYRES)-y)-1;
// Too big
if (x + w > VIDXRES)
return;
// Starts off the top of the screen, adjust
if (y < 0 && -y < h)
{
img += -y*w;
h += y;
y = 0;
}
if(!h || y < 0) return;
if(a >= 255)
for (j=0; j<h; j++)
for (i=0; i<w; i++)
// Starts off the left side of the screen, adjust
if (x < 0 && -x < w)
{
startX = -x;
}
if (!h || y < 0 || !w)
return;
if (a >= 255)
for (int j = 0; j < h; j++)
{
img += startX;
for (int i = startX; i < w; i++)
{
vid[(y+j)*(VIDXRES)+(x+i)] = *img;
img++;
}
}
else
for (j=0; j<h; j++)
for (i=0; i<w; i++)
{
int r, g, b;
for (int j = 0; j < h; j++)
{
img += startX;
for (int i = startX; i < w; i++)
{
r = PIXR(*img);
g = PIXG(*img);
b = PIXB(*img);
blendpixel(x+i, y+j, r, g, b, a);
img++;
}
}
}
}
void PIXELMETHODS_CLASS::draw_image(const VideoBuffer & vidBuf, int x, int y, int a)

0 comments on commit d4a0ff9

Please sign in to comment.