-
Notifications
You must be signed in to change notification settings - Fork 22
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
png codec doesn't support non indexed grayscale #163
Comments
Hi! SAIL always tries to write pixels as closer to the source pixels as possible. With png, it always writes source pixels. If you want to save a grayscale image as a 24bit rgb, the only way is to convert the image to 24bit beforehand. There are two conversion methods: 1. Modifying: Overwrite the original image 2. Const: Return a converted image Hope this helps |
Hi! thanks for your reply. Not sure though if I've explained my issue clearly. I have a procedurally generated image in memory coming from external tool. It's a grayscale image and it can have a different precision. So I wanted to save it as a grayscale png. This is what I did: auto image = sail::image(texture.buffer, SAIL_PIXEL_FORMAT_BPP8_GRAYSCALE, texture.level0Width, texture.level0Height);
image.save("myfile.png"); // this won't work (sail says it's not supported pixel format)
image.convert(SAIL_PIXEL_FORMAT_BPP8_INDEXED); // this one also not supported
// the only workaround I've found is this and it's not ideal:
image.convert(SAIL_PIXEL_FORMAT_BPP24_RGB);
image.save("myfile.png"); The same goes with 16 bit grayscale. Am I missing something here? Thanks! |
Oh, I see. Let me check and get back to you. |
Yeah, the png implementation doesn't support grayscale images. See https://github.com/HappySeaFox/sail/blob/master/src/sail-codecs/png/png.codec.info.in (there is no grayscale in the list) . I don't really remember the actual reason behind that. Let me investigate more. |
It looks like an artifact of the old-era SAIL. Technically, now we have no reasons for not supporting grayscale image. |
Please wait for the next available release in Or, if you feel comfortable, you can try patching SAIL locally in your current copy of |
Great!😃 Yes, |
basically if I just check formats with
sail::codec_info::from_extension("png").write_features().output_pixel_formats()
it just gives me this list:13,14,15,16,31,32,33,34,47,48,49,50,55,56,57,58
I've tried to write png image from grayscale buffer but didn't actually find an obvious way to do that (apart from converting it to rgb which I'd like to avoid)
is that intended? or it's something with my build (I just installed it from vcpkg)
The text was updated successfully, but these errors were encountered: