Does and should this library support images with subpixel types that are signed integers? #2851
RunDevelopment
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been thinking about this recently, while looking at
Primitive,Pixeland functions consuming them.A lot of functions just don't handle signed ints correctly, and I don't blame them. Random example:
brighten:See that 0 in
clamp?brigthenassumes that 0 is the minimum value. Which is true for floating point types and unsigned integer types, but not signed integer types. Just from looking through them briefly, it seems like all color ops make that assumption.Basically everything in
src/color.rsalso makes that assumption. For example:Note that the subtraction can overflow for signed types. E.g. for
i8, it's possible to calculate127 - (-13). This either panics in debug mode or silently produces wrong results in release mode.I want to stress that these are random examples. I didn't look for hours until I found something. Examples like this are extremely easy to find, because the whole codebase seems to collectively ignore signed integer types. I too have written code with issues like this, because I didn't even consider signed int types until I found that they implement
Primitive.So what level of support is there for signed integer types as subpixel types? Should they be supported? If so, is the amount of work required to support them properly worth the effort?
Beta Was this translation helpful? Give feedback.
All reactions