mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-03-31 12:33:00 +02:00
draw_image can now draw images with x<0, fixes #433
this isn't used at all in the source
This commit is contained in:
parent
0ea5c1d0e0
commit
d4a0ff9ac8
@ -445,26 +445,48 @@ 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);
|
||||
@ -472,6 +494,8 @@ void PIXELMETHODS_CLASS::draw_image(pixel *img, int x, int y, int w, int h, int
|
||||
blendpixel(x+i, y+j, r, g, b, a);
|
||||
img++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PIXELMETHODS_CLASS::draw_image(const VideoBuffer & vidBuf, int x, int y, int a)
|
||||
|
Loading…
x
Reference in New Issue
Block a user