mirror of
https://github.com/reactos/reactos.git
synced 2025-05-22 18:45:00 +00:00
[CORE-8302]
Fix aspect ratio calculation in shell image viewer. Patch by Ricardo Hanke. svn path=/trunk/; revision=65609
This commit is contained in:
parent
cbc7920dbe
commit
0188f94d85
1 changed files with 9 additions and 47 deletions
|
@ -352,65 +352,27 @@ ImageView_DrawImage(HWND hwnd)
|
||||||
{
|
{
|
||||||
FillRect(hdc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
FillRect(hdc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
||||||
|
|
||||||
if ((rect.right == uImgWidth)&&(rect.bottom == uImgHeight))
|
if ((rect.right >= uImgWidth)&&(rect.bottom >= uImgHeight))
|
||||||
{
|
{
|
||||||
x = 0, y = 0, width = rect.right, height = rect.bottom;
|
|
||||||
}
|
|
||||||
else if ((rect.right >= uImgWidth)&&(rect.bottom >= uImgHeight))
|
|
||||||
{
|
|
||||||
x = (rect.right/2)-(uImgWidth/2);
|
|
||||||
y = (rect.bottom/2)-(uImgHeight/2);
|
|
||||||
width = uImgWidth;
|
width = uImgWidth;
|
||||||
height = uImgHeight;
|
height = uImgHeight;
|
||||||
}
|
}
|
||||||
else if ((rect.right < uImgWidth)||(rect.bottom < uImgHeight))
|
else
|
||||||
{
|
{
|
||||||
if (rect.bottom < uImgHeight)
|
height = uImgHeight * (UINT)rect.right / uImgWidth;
|
||||||
{
|
if (height <= rect.bottom)
|
||||||
height = rect.bottom;
|
|
||||||
width = uImgWidth*(UINT)rect.bottom/uImgHeight;
|
|
||||||
x = (rect.right/2)-(width/2);
|
|
||||||
y = (rect.bottom/2)-(height/2);
|
|
||||||
}
|
|
||||||
if (rect.right < uImgWidth)
|
|
||||||
{
|
{
|
||||||
width = rect.right;
|
width = rect.right;
|
||||||
height = uImgHeight*(UINT)rect.right/uImgWidth;
|
|
||||||
x = (rect.right/2)-(width/2);
|
|
||||||
y = (rect.bottom/2)-(height/2);
|
|
||||||
}
|
}
|
||||||
if ((height > rect.bottom)||(width > rect.right))
|
else
|
||||||
{
|
{
|
||||||
for (;;)
|
width = uImgWidth * (UINT)rect.bottom / uImgHeight;
|
||||||
{
|
height = rect.bottom;
|
||||||
if (((int)width - 1 < 0)||((int)height - 1 < 0)) break;
|
|
||||||
width -= 1;
|
|
||||||
height -= 1;
|
|
||||||
y = (rect.bottom/2)-(height/2);
|
|
||||||
x = (rect.right/2)-(width/2);
|
|
||||||
if ((height < rect.bottom)&&(width < rect.right)) break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((rect.right <= uImgWidth)&&(rect.bottom <= uImgHeight))
|
|
||||||
{
|
|
||||||
height = uImgHeight*(UINT)rect.right/uImgWidth;
|
|
||||||
y = (rect.bottom/2)-(height/2);
|
|
||||||
width = rect.right;
|
|
||||||
|
|
||||||
if ((height > rect.bottom)||(width > rect.right))
|
y = (rect.bottom / 2) - (height / 2);
|
||||||
{
|
x = (rect.right / 2) - (width / 2);
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if (((int)width - 1 < 0)||((int)height - 1 < 0)) break;
|
|
||||||
width -= 1;
|
|
||||||
height -= 1;
|
|
||||||
y = (rect.bottom/2)-(height/2);
|
|
||||||
x = (rect.right/2)-(width/2);
|
|
||||||
if ((height < rect.bottom)&&(width < rect.right)) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("x = %d\ny = %d\nWidth = %d\nHeight = %d\n\nrect.right = %d\nrect.bottom = %d\n\nuImgWidth = %d\nuImgHeight = %d\n", x, y, width, height, rect.right, rect.bottom, uImgWidth, uImgHeight);
|
DPRINT("x = %d\ny = %d\nWidth = %d\nHeight = %d\n\nrect.right = %d\nrect.bottom = %d\n\nuImgWidth = %d\nuImgHeight = %d\n", x, y, width, height, rect.right, rect.bottom, uImgWidth, uImgHeight);
|
||||||
Rectangle(hdc, x - 1, y - 1, x + width + 1, y + height + 1);
|
Rectangle(hdc, x - 1, y - 1, x + width + 1, y + height + 1);
|
||||||
|
|
Loading…
Reference in a new issue