From 46296918d86d54a16a4f5f3da92033dcb600b4a7 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Mon, 27 Jun 2022 19:26:56 +0100 Subject: [PATCH] Fix regression where OriginalFill images would never show Fixes #3102 --- CHANGELOG.md | 1 + internal/painter/image.go | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc0a84b85a..d6bbe9f504 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ More detailed release notes can be found on the [releases page](https://github.c * Emphasis in Markdown gives erroneous output in RichText (#2974) * When last visible window is closed, hidden window is set visible (#3059) * Do not close app when last window is closed but systrayMenu exists (#3092) +* Image with ImageFillOriginal not showing (#3102) ## 2.2.1 - 12 June 2022 diff --git a/internal/painter/image.go b/internal/painter/image.go index 3cf59c7673..93e453fa61 100644 --- a/internal/painter/image.go +++ b/internal/painter/image.go @@ -46,8 +46,8 @@ func PaintImage(img *canvas.Image, c fyne.Canvas, width, height int) image.Image var wantOrigW, wantOrigH int wantOrigSize := false if img.FillMode == canvas.ImageFillOriginal && c != nil { - wantOrigW = internal.ScaleInt(c, img.Size().Width) - wantOrigH = internal.ScaleInt(c, img.Size().Height) + wantOrigW = internal.ScaleInt(c, img.MinSize().Width) + wantOrigH = internal.ScaleInt(c, img.MinSize().Height) wantOrigSize = true } @@ -124,12 +124,14 @@ func paintImage(img *canvas.Image, width, height int, wantOrigSize bool, wantOri } origSize := pixels.Bounds().Size() + origW, origH = origSize.X, origSize.Y if checkSize(origSize.X, origSize.Y) { dst = scaleImage(pixels, width, height, img.ScaleMode) } } case img.Image != nil: origSize := img.Image.Bounds().Size() + origW, origH = origSize.X, origSize.Y if checkSize(origSize.X, origSize.Y) { dst = scaleImage(img.Image, width, height, img.ScaleMode) }