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@gmail.com>
This commit is contained in:
parent
d2d4866dd4
commit
db6fcb750a
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user