How do I create a transparent gif in Go? -
when encode gif in go, background black. how make background transparent?
here code in http handler. (w responsewriter)
m := image.newrgba(image.rect(0, 0, pixelwidth, pixelheight)) gif.encode(w, m, &gif.options{numcolors: 16})
i read source of image/gif , found there has transparent color on palette.
var palette color.palette = color.palette{ image.transparent, image.black, image.white, color.rgba{0, 255, 0, 255}, color.rgba{0, 100, 0, 255}, } m := image.newpaletted(image.rect(0, 0, pixelwidth, pixelheight), palette) gif.encode(w, m, &gif.options{})
Comments
Post a Comment