golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.09k stars 17.68k forks source link

image: NewPaletted generated picture is not clear #17685

Closed zouhuigang closed 8 years ago

zouhuigang commented 8 years ago
f8, err := os.Open("734.jpg")
if err != nil {
    fmt.Println(err)
}
defer f8.Close()

g8, err := jpeg.Decode(f8)
if err != nil {
    fmt.Println(err)
}

//p8 := image.NewPaletted(image.Rect(0, 0, 150, 150), palette.Plan9)
p8 := image.NewRGBA(image.Rect(0, 0, 150, 150))
draw.Draw(p8, p8.Bounds(), g8, image.ZP, draw.Over) //添加图片
imgcounter3 := 738
saveImage(fmt.Sprintf("%03d.jpg", imgcounter3), p8)
zouhuigang commented 8 years ago

Generate an animated GIF from static images: before

after

bradfitz commented 8 years ago

For help with Go, see https://golang.org/wiki/Questions

Maybe your question is about dithering. See https://en.wikipedia.org/wiki/Floyd%E2%80%93Steinberg_dithering which is also built in to the standard library: https://golang.org/pkg/image/draw/#Drawer