Preserve aspect ratio of the screenshot in the preview. (Ticket #3821)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30457 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Saint-Pierre 2009-04-27 13:48:56 +00:00
parent 2ae836dbe0
commit 2002f6f626

View File

@ -502,6 +502,21 @@ ScreenshotWindow::_CenterAndShow()
void
ScreenshotWindow::_UpdatePreviewPanel()
{
float height = 150.0f;
float width = (fScreenshot->Bounds().Width() /
fScreenshot->Bounds().Height()) * height;
// to prevent a preview way too wide
if (width > 400.0f) {
width = 400.0f;
height = (fScreenshot->Bounds().Height() /
fScreenshot->Bounds().Width()) * width;
}
fPreviewBox->SetExplicitMinSize(BSize(width, height));
fPreviewBox->SetExplicitMaxSize(BSize(width, height));
fPreviewBox->ClearViewBitmap();
fPreviewBox->SetViewBitmap(fScreenshot, fScreenshot->Bounds(),
fPreviewBox->Bounds(), B_FOLLOW_ALL, 0);