2

I have tried to display a photo in a Fyne window but it is much smaller than I want it.

With a window name "w", I used "w.setContent()" to display the photo. However, it is tiny and in the top left corner. I want to control the dimensions of the photo. How do I do this?

png.Encode(myFile, myImage)
defer myFile.Close()

thisImage := canvas.NewImageFromFile(imagePath)
thisImage.FillMode = canvas.ImageFillOriginal
fmt.Println("checking window: ", w)
fmt.Println("checking image", thisImage)
w.SetContent(thisImage)

1 Answers1

0

Beware of not closing the image before you read it again - not sure if that’s what the first two lines are about.

The fill mode ImageFillOriginal asks Fyne to display 1 pixel on screen for each pixel on your photo. If you want it to fill the window that is probably not desirable. Try removing that line from your example and it will fill the window.

andy.xyz
  • 2,567
  • 1
  • 13
  • 18