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

High banding in the gradients generated by gg #24

Open
tariq1890 opened this issue Aug 24, 2017 · 6 comments
Open

High banding in the gradients generated by gg #24

tariq1890 opened this issue Aug 24, 2017 · 6 comments

Comments

@tariq1890
Copy link

The banding is really high. Is there any way to reduce this for the generated images?

@tariq1890
Copy link
Author

@fogleman Could you help us with this? Is there anything we must do to ensure less banding in the gradients generated.

This is a great library for generating gradients since its very simple and intuitive. It's unfortunate that we get such high banding.

@fogleman
Copy link
Owner

Can you post code and an image showing the effect? I don't see an issue in the gradient examples.

@tariq1890
Copy link
Author

grad := gg.NewLinearGradient(0, 0, 1920, 0)
	grad.AddColorStop(0, color.RGBA{0, 0, 0, 200})
	grad.AddColorStop(1, color.RGBA{0, 0, 0, 128})

	dc.SetFillStyle(grad)
	dc.MoveTo(0, 0)
	dc.LineTo(1920, 0)
	dc.LineTo(1920, 1080)
	dc.LineTo(0, 1080)
	dc.ClosePath()
	dc.Fill()
	gradientOverlay := dc.Image()
	imaging.Save(gradientOverlay, "out.png")

out

@fogleman
Copy link
Owner

Well the only way to improve that would be to go to a 16-bit image.

Currently gg only does 8-bit. It wouldn't be too hard to do 16-bit but might be API-breaking.

@tariq1890
Copy link
Author

Oh alright! Is it possible to create a v2 package? I am also happy to help through PRs if you can give me an overview of the places that require changing.

@fogleman
Copy link
Owner

It would start by changing RGBA -> NRGBA64 and Alpha -> Alpha16 throughout the code.

But it might not actually be so easy. The freetype/raster package which gg is built upon only seems to support RGBA and Alpha.

https://github.com/golang/freetype/blob/master/raster/paint.go

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