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

Pointer to image.Image interface #3

Closed
diamondburned opened this issue Jul 26, 2020 · 1 comment
Closed

Pointer to image.Image interface #3

diamondburned opened this issue Jul 26, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@diamondburned
Copy link

This library has the Encode API take in a pointer to image.Image (*image.Image) instead of either the interface itself (which has an underlying value of a pointer) or a concrete struct such as *image.NRGBA. This is usually a bad idea.

The lines that use this "pointer to interface" seem to only dereference the interface and not change it:

https://github.com/buckket/go-blurhash/blob/master/encode.go#L110-L111

height := (*rgba).Bounds().Max.Y
width := (*rgba).Bounds().Max.X

https://github.com/buckket/go-blurhash/blob/master/encode.go#L131

rt, gt, bt, _ := (*rgba).At(x, y).RGBA()
@buckket buckket self-assigned this Jul 26, 2020
@buckket buckket added the enhancement New feature or request label Jul 26, 2020
@buckket
Copy link
Owner

buckket commented Jul 26, 2020

You’re correct. I can’t recall why I’ve chosen *image.Image, it’s not necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants