From 2002f6f6269e21a3c1f8208e452c707aac2c9890 Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Mon, 27 Apr 2009 13:48:56 +0000 Subject: [PATCH] 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 --- src/apps/screenshot/ScreenshotWindow.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/apps/screenshot/ScreenshotWindow.cpp b/src/apps/screenshot/ScreenshotWindow.cpp index cc99873273..9c7e5be0f6 100644 --- a/src/apps/screenshot/ScreenshotWindow.cpp +++ b/src/apps/screenshot/ScreenshotWindow.cpp @@ -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);