Encoder supported colors#2992
Conversation
I would say it is bad considering the use of That said, my bigger concern is the interface and conversion algorithm being underspecified. Conversions between two of the same depths is not lossless if it requires changing color space in the process for instance. So, is a list of possible color models really enough information to decide on a conversion sequence in the general case? I'm not against changing the internal interface so much as making it public is not motivated strongly enough for me. |
I'm not really sure why you say any of this. The current conversion is for After all, I'm not suggesting expanding these conversions to cover all save/write methods (e.g. the ones on
It seems to me that you are conflating the interface ( I see
I think lossy conversions and loss of color space information aren't a huge issue here. That said, if they are an issue, we can also just not do them. Conversions are best effort and refusing to perform non-trivial conversions (like RGB -> gray) seems fine to me. |
Resolves #2990
Changes:
ImageEncoder::supported_colors.make_compatible_imgmake_compatible_imgutil method based onsupported_colorsImageEncoder::supported_colorscorrectly.I quickly implemented my proposal. Basically, instead of encoders implementing how to convert a dynamic image to something compatible, they now declare what is compatible. This makes it possible to have a unified conversion function for all encoders.
Open questions:
ImageEncoder::supported_colors? Right now, I only implemented it for the encoders that previously implementedmake_compatible_imgto get equivalent behavior.make_compatible_imgis potentially quite heavy in terms of code size. It needs the full matrix of conversions between color types and is not generic. Now, this might sound really bad, but it's not that bad. The 10x10 color types quickly map toCicpRgb::cast_pixels_by_layout, which is generic over the to and from sub-pixel type. So there are only 3x3 heavy functions being monomorphized. Still, not necessarily super good.