tannerhelland / PhotoDemon

A free portable photo editor focused on pro-grade features, high performance, and maximum usability.
https://photodemon.org
Other
1.36k stars 200 forks source link

About RGB565 #275

Open runner111 opened 5 years ago

runner111 commented 5 years ago

Hello, Thanks for your greate job. Could you add function: RGB888 to RGB565? Now, in save, the convert will lost some detail. And I found you have dithering function, how about output dithering RGB565?

tannerhelland commented 5 years ago

Hi runner111. Thank you for the suggestion!

Can you elaborate on your suggestion for me? Do you want to write 16-bit BMP files in 5-6-5 format? Or do you just want to produce 5-6-5 images using some kind of effect?

If it is the latter, you can use the Effects > Artistic > Posterize tool to produce 5-6-5 data. Just set red to 32 colors, green to 64 colors, and blue to 32 colors. There is also an option there for dithering (but not a very powerful one; I could expand it to include more dithering options).

If it is the former, I should note that PhotoDemon currently uses 3rd-party library for writing BMP files. If I rewrote the BMP export code myself, it would be possible to add things like dithering and RGB565 output.

If that's what you would like, can you let me know your use-case for 16-bit BMP files? This is not a file format I use frequently, and I would need to study the way other software handles it (to make sure I am not creating any compatibility issues by switching from 5-5-5 to 5-6-5).

Thank you for any clarification you can provide.

gingerbeardman commented 5 years ago

Hope it's ok for me to chime in.

I've recently had to create 16bpp BMP RGB565 images for Nintendo DSi. https://github.com/DS-Homebrew/TWiLightMenu/blob/master/romsel_dsimenutheme/resources/dsimenu_theme_examples/theming.md

I eventually found that GIMP can save them so I use that. The option is on its BMP options. https://apple.stackexchange.com/a/346024/15281

tannerhelland commented 5 years ago

Hi @gingerbeardman . Thank you for chiming in! It's great to hear additional perspectives on this.

Just to quickly clarify - PhotoDemon's nightly build, when saving 16-bpp BMP files, currently uses RGB565 format by default:

image

There is also a toggle for the old 5-5-5 format.

When selecting the 565 (or 555) color format, PhotoDemon automatically converts the current image to 565 format but it does not use dithering.

I would like to add dithering as an export option, but it's a little messy as I need to add the option for not just 16-bit files, but 8-bit color and grayscale as well. So it's a lot of work for a relatively niche use-case. In the meantime, there's the Effects > Artistic > Posterize workaround described above; it's not ideal, but it will produce a "maximum quality" 565 result.

gingerbeardman commented 5 years ago

I'll try the nightly!

Off topic, but did you ever see the source code for the original Photoshop? It's written in the most well structured (Pascal) code I've ever seen. Mirror here: https://github.com/amix/photoshop

tannerhelland commented 5 years ago

Thank you for the link to the PS code archive! I'll have to peruse it in more detail. It's incredible what the original authors were able to accomplish despite severe hardware constraints. (It also makes me want to spend weeks/months/years cleaning up my own code, heh)