- Fixed: DCanvas::Dim() and DCanvas::Clear() did not clamp their coordinates to the screen.

SVN r3457 (trunk)
This commit is contained in:
Randy Heit 2012-03-20 02:20:06 +00:00
parent 2e9abe7408
commit 0552f04e4c
2 changed files with 26 additions and 0 deletions

View file

@ -1086,6 +1086,15 @@ void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uin
assert(left < right);
assert(top < bottom);
if (left >= Width || right <= 0 || top >= Height || bottom <= 0)
{
return;
}
left = MAX(0,left);
right = MIN(Width,right);
top = MAX(0,top);
bottom = MIN(Height,bottom);
if (palcolor < 0)
{
if (APART(color) != 255)

View file

@ -348,6 +348,23 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h)
BYTE *spot;
int x, y;
if (x1 >= Width || y1 >= Height)
{
return;
}
if (x1 + w > Width)
{
w = Width - x1;
}
if (y1 + h > Height)
{
h = Height - y1;
}
if (w <= 0 || h <= 0)
{
return;
}
{
int amount;