canvas
canvas copied to clipboard
How to save canvas as png with transparent background
I want save canvas as png photo. But the background is always black.
fDst, err := os.Create("out2.png")
if err != nil {
log.Fatal(err)
}
defer fDst.Close()
err = png.Encode(fDst, cv.GetImageData(0, 0, cv.Width(), cv.Height()))
if err != nil {
log.Fatal(err)
}
wnd.Close()
Sorry for missing this. I'll answer now just for completeness I guess.
GetImageData currently only returns the RGB channels, no alpha. At the moment the only way to get alpha would be to use the software rendering backend, but obviously then the performance will be bad.