-
-
Notifications
You must be signed in to change notification settings - Fork 717
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
core:image add support for option .flip_vertical #4826
base: master
Are you sure you want to change the base?
Conversation
My opinion on this, (but would love a review from @Kelimion) is that the helper function is a nice addition but having it as an option on top isn't needed. |
core/image/common.odin
Outdated
@@ -146,6 +148,7 @@ Option :: enum { | |||
alpha_drop_if_present, // Unimplemented for QOI. Returns error. | |||
alpha_premultiply, // Unimplemented for QOI. Returns error. | |||
blend_background, // Ignored for non-PNG formats | |||
vertical_flip, // flip image vertically on load |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the other comments, I'd capitalize // Flip
.
core/image/common.odin
Outdated
@@ -1438,6 +1441,17 @@ expand_grayscale :: proc(img: ^Image, allocator := context.allocator) -> (ok: bo | |||
return true | |||
} | |||
|
|||
vertical_flip :: proc(img: ^Image) { | |||
pixels := img.pixels.buf[:] | |||
bpp := img.depth/8 * img.channels |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This proc should probably have a comment that it only supports 8 and 16 bpp, and an assert at the top that enforces this.
For completeness, it would be great if this new option had some testing as well. Maybe a handful of images of 8 and 16 bpp that we load twice, once with |
This is basically the same as the option in stb_image to flip an image. One common use case is loading images for OpenGL which expects pixel data to be upside down, unlike most other graphics APIs and image formats.
small cleanups: - doc comments for proc and option - make whitespace consistent - make comment capitalization consistent
d40e436
to
be6ff42
Compare
I agree in principle. Still there are reasons, both very minor, admittedly, to include the option:
|
@Kelimion |
TGA as well. See the variable |
Alright, I am fine with the option then |
This is basically the same as the option in stb_image to flip an image. One common use case is loading images for OpenGL which expects pixel data to be upside down, unlike most other graphics APIs and image formats.
I'm not super sure if this is useful to most people, plus it's trivial to write yourself if you do need it, so no problem if you decide not to accept this PR just for irrelevance :)