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

image: YCbCr lacks Set #9941

Closed
josharian opened this issue Feb 20, 2015 · 2 comments
Closed

image: YCbCr lacks Set #9941

josharian opened this issue Feb 20, 2015 · 2 comments

Comments

@josharian
Copy link
Contributor

This means that is not usable out of the box with the image/draw package. Is this an oversight, or is there a particular reason for the omission?

/cc @nigeltao

@nigeltao
Copy link
Contributor

Quoting myself from https://www.mattcutts.com/blog/photo-mosaic-effect-with-go/#comment-102923


You can’t set the pixels of an image.YCbCr (i.e. a JPEG image) directly, because the underlying data doesn’t map 1:1 to pixels, due to chroma sub-sampling. If you know what you’re doing, and are aware that setting one Chroma sample can affect multiple pixels, then the image.YCbCr struct exposes enough to let you set pixels. But if you don’t know what you’re doing, then we figured it’d be less dangerous to disallow behavior (setting pixels) than have potentially surprising behavior.

http://en.wikipedia.org/wiki/Chroma_subsampling

In general, work in RGBA as long as you can. The jpeg Encoder converts to YCbCr just before writing bits on the wire, but the intention is that you draw on your RGBA and pass your RGBA to jpeg.Encode.

@nigeltao
Copy link
Contributor

By "disallow behavior", I should have said "not easily expose behavior".

@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants