[haiku-commits] haiku: hrev53516 - src/apps/people

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 25 Sep 2019 19:44:09 -0400 (EDT)

hrev53516 adds 1 changeset to branch 'master'
old head: d2d4866dd448fdcd8a336a904562a044060100d9
new head: db6fcb750a1afb5fdc752322972adf6044d3b4c4
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=db6fcb750a1a+%5Ed2d4866dd448

----------------------------------------------------------------------------

db6fcb750a1a: People: fix aspect ratio for square images
  
  If you dropped a square image onto the image well, it was
  squashed horizontally.
  
  Change-Id: Ie5637fc242a1c5b7313234a87822bc43556cbe4d
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/1886
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

                                        [ Humdinger <humdingerb@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev53516
Commit:      db6fcb750a1afb5fdc752322972adf6044d3b4c4
URL:         https://git.haiku-os.org/haiku/commit/?id=db6fcb750a1a
Author:      Humdinger <humdingerb@xxxxxxxxx>
Date:        Mon Sep 23 18:38:29 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Wed Sep 25 23:44:04 2019 UTC

----------------------------------------------------------------------------

1 file changed, 6 insertions(+), 3 deletions(-)
src/apps/people/PictureView.cpp | 9 ++++++---

----------------------------------------------------------------------------

diff --git a/src/apps/people/PictureView.cpp b/src/apps/people/PictureView.cpp
index 837bd7df99..6ced2ab40d 100644
--- a/src/apps/people/PictureView.cpp
+++ b/src/apps/people/PictureView.cpp
@@ -275,10 +275,13 @@ PictureView::Draw(BRect updateRect)
                BRect frame = rect.InsetByCopy(kPictureMargin, kPictureMargin);
                BRect srcRect = picture->Bounds();
                BSize size = frame.Size();
-               if (srcRect.Width() > srcRect.Height())
-                       size.height = srcRect.Height() * size.width / 
srcRect.Width();
-               else
+               float pictureAspect = srcRect.Height() / srcRect.Width();
+               float frameAspect = size.height / size.width;
+
+               if (pictureAspect > frameAspect)
                        size.width = srcRect.Width() * size.height / 
srcRect.Height();
+               else if (pictureAspect < frameAspect)
+                       size.height = srcRect.Height() * size.width / 
srcRect.Width();
 
                fPictureRect = BLayoutUtils::AlignInFrame(frame, size,
                        BAlignment(B_ALIGN_HORIZONTAL_CENTER, 
B_ALIGN_VERTICAL_CENTER));


Other related posts:

  • » [haiku-commits] haiku: hrev53516 - src/apps/people - waddlesplash