Comments (4)
Shouldn't color_type be of type enum spng_color_type rather than uint8_t ?
The fields have the same size as the described by the file format, but I'll probably change that for the next breaking version.
it's pretty confusing to have two different types enum spng_color_type and enum spng_format that have names with identical meaning
When decoding you're converting from ihdr
to an spng_format
, or from an spng_format
to an ihdr
when encoding. Formats are different, it's color type, channel order, bit depth and endianness in one enum except for SPNG_FMT_PNG
, SPNG_FMT_RAW
which only specify endianness and the rest is derived from ihdr
.
from libspng.
The fields have the same size as the described by the file format
Correct. The issue is that you can assign a spng_format to uint8_t color_type due to enum implicitly cast to int. It's much better if the static checker to throw an error in this case.
When decoding you're converting from ihdr to an spng_format, or from an spng_format to an ihdr when encoding.
Thanks for the clarification. I understand the rational for having different types between encoding and decoding steps.
I will try to clarify the point I was trying to make with truecolor.
https://en.wikipedia.org/wiki/Color_depth#True_color_(24-bit)
True color (24-bit), the use of 24 bits to store color information
24 bits almost always use 8 bits each of R, G, and B
Therefore,
"TRUECOLOR" and "RGB8" have the exact same semantic meaning and it's confusing to try and understand why the API uses different words for the same thing.
In my opinion something like:
SPNG_COLOR_TYPE_RGBA8
SPNG_FMT_RGBA8
Makes it expressly clear that we are talking about a color type and a fmt type. Perhaps I will just make this a typedef for myself if you are not interested in changing the API.
from libspng.
The standard uses the term "truecolor", at the time it made sense to use the exact same words.
I wouldn't add something like SPNG_COLOR_TYPE_RGBA8
because the standard expresses color type and bit depth in separate fields. Some PNG libraries also have *_COLOR_TYPE_RGBA
but bit depth is still a separate value.
Makes it expressly clear that we are talking about a color type and a fmt type.
But they already start with SPNG_COLOR_TYPE
and SPNG_FMT
🤔
from libspng.
Doesn't seem too far of a reach to have a COLOR_TYPE that combines the "truecolour"-ness and the 8 or 16 bit-ness in a single flag. That's just an observation. I see now that would be innovating on the standard a little bit. From a practical standpoint I was surprised to not see it is all. Take it for what it's worth.
from libspng.
Related Issues (20)
- Support for Windows BMP HOT 1
- SPNG_FMT_PNG is big-endian even while little-endian system HOT 5
- spng_encode_image doesn't fail if a pixel index is bigger than spng_plte::n_entries HOT 2
- Add option to check palette indices
- Debian packaging HOT 14
- Clang: error: type '_Float32' (aka 'float') in generic association compatible with previously specified type 'float' HOT 1
- Decode RGB16 / G16 HOT 3
- accept a possible invalid png file HOT 2
- Compatibility with PNG images with zero-length EXIF chunk HOT 3
- Consider revising error handling for large chunks
- Simple error in libspng site HOT 1
- accept a possible problematic png image silently HOT 5
- Error linking libspng functions when compiling Mingw-w64 project HOT 4
- Example for spng_set_png_stream() HOT 1
- Indexed .PNGs don't seem to handle alpha channel correctly HOT 1
- Website basic usage example has wrong parameter order for spng_decode_image() HOT 1
- No subimage when creating an image from scratch HOT 1
- Missing check in function check_time HOT 1
- Feature request: ability to disable CMake install targets
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libspng.