You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi !
This code creates a "saveImage" function to save a very large multilayer image to a file. In my code I pass the content of the saveimage() function which produces the multilayer fyne.CanvasObject to the software.Render() function which is triggered by a save button . This code produces a panic because, according to Andrew "it is necessary to remove ImageFillOriginal beacuse to do an original image fill it needs a 2 pass process which it seems does not work for the 1-pass draw of a software renderer"
Example code:
package main
import (
"fyne.io/fyne/v2""fyne.io/fyne/v2/app""fyne.io/fyne/v2/canvas""fyne.io/fyne/v2/container""fyne.io/fyne/v2/driver/software""fyne.io/fyne/v2/theme""fyne.io/fyne/v2/widget""image""image/color""image/png""log""os"
)
funcmain() {
a:=app.New()
w:=a.NewWindow("Sign")
w.SetContent(container.NewScroll(makePicture()))
w.Resize(fyne.NewSize(120, 120))
w.Show()
// save image buttonw2:=a.NewWindow("Tool Box")
but:=widget.NewButton("screenshot", func() {
// save the scroll containt to filepic:=makePicture()
pic.Resize(fyne.NewSize(200, 200))
img:=software.Render(pic, theme.DarkTheme())
saveimage(img)
})
w2.SetContent(but)
w2.ShowAndRun()
w.ShowAndRun()
}
funcmakePicture() fyne.CanvasObject {
image:=canvas.NewImageFromFile("image.png")
image.FillMode=canvas.ImageFillOriginal// this line is responsible for the bugbg:=canvas.NewCircle(color.NRGBA{255, 0, 0, 255})
bg.StrokeColor=color.Whitebg.StrokeWidth=5bg.Resize(fyne.NewSize(100, 100))
bg.Move(fyne.NewPos(10, 10))
c:=container.NewMax(image, bg)
returnc
}
funcsaveimage(out image.Image) {
path:="test.png"outputFile, err:=os.Create(path)
iferr!=nil {
log.Println("The image cannot be saved to the file")
}
png.Encode(outputFile, out)
log.Println("Saving image to ", path)
outputFile.Close()
}
Device :
Linux Manjaro
Go version: 1.6.3
Fyne version: 2.0.3
Hi !
This code creates a "saveImage" function to save a very large multilayer image to a file. In my code I pass the content of the saveimage() function which produces the multilayer fyne.CanvasObject to the
software.Render()
function which is triggered by a save button . This code produces a panic because, according to Andrew "it is necessary to removeImageFillOriginal
beacuse to do an original image fill it needs a 2 pass process which it seems does not work for the 1-pass draw of a software renderer"Example code:
Device :
Linux Manjaro
Go version: 1.6.3
Fyne version: 2.0.3
The error :
The text was updated successfully, but these errors were encountered: