Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image jumps #1432

Closed
stuartmscott opened this issue Oct 20, 2020 · 1 comment
Closed

Image jumps #1432

stuartmscott opened this issue Oct 20, 2020 · 1 comment

Comments

@stuartmscott
Copy link
Member

Describe the bug:

Similar to #1266, but for ImageFillOriginal

Example code:

Run the below with any jpeg image as go run main.go /path/to/image.jpg

package main

import (
	"bytes"
	"fyne.io/fyne"
	"fyne.io/fyne/app"
	"fyne.io/fyne/canvas"
	"fyne.io/fyne/widget"
	"image/jpeg"
	"io/ioutil"
	"log"
	"os"
)

func main() {
	// Create Fyne App
	a := app.New()

	// Create Fyne Window
	w := a.NewWindow("Image Jump")

	// Create image to hold image
	img := &canvas.Image{
		FillMode: canvas.ImageFillOriginal,
	}
	scroller := widget.NewScrollContainer(img)

	// Create goroutine to load file contents and update image
	go func() {
		data, err := ioutil.ReadFile(os.Args[1])
		if err != nil {
			log.Println("Error:", err)
			return
		}
		i, err := jpeg.Decode(bytes.NewReader(data))
		if err != nil {
			log.Println("Error:", err)
			return
		}
		img.Image = i
		img.Refresh()
		scroller.Refresh()
	}()

	// Add scroller to window
	w.SetContent(scroller)

	w.Resize(fyne.NewSize(480, 600))
	w.ShowAndRun()
}
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Oct 21, 2020
This is not pretty but what we have to do is return the visible portion pixel for pixel.
The image is immediately refreshed so the correct, full, image (with aspect applied) is then used.

Fixes fyne-io#1432
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Oct 22, 2020
Just skip frame 1 the flicker goes :)

Fixes fyne-io#1432
andydotxyz added a commit that referenced this issue Oct 22, 2020
Just skip frame 1 the flicker goes :)

Fixes #1432
@andydotxyz
Copy link
Member

On develop :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants