kopaka1822 / ImageViewer

HDR, PFM, DDS, KTX, EXR, PNG, JPG, BMP image viewer and manipulator
MIT License
331 stars 37 forks source link

Add the ability to change the color space of the image and save it with the applied parameter #33

Closed IvanSCP closed 10 months ago

IvanSCP commented 10 months ago

I would like to get an opportunity where you can change the color space of an image and then save it with the selected space.

Imagination's PVRTexTool has the ability to view an image with the desired color space, but unfortunately it cannot be applied to an image and saved. I suggest adding this solution to ImageViewer, making it unique :)

https://github.com/kopaka1822/ImageViewer/assets/126201100/d4f020d3-d6d2-48c3-921e-bb8a5b7eb1ca

kopaka1822 commented 10 months ago

Hi, I think the image viewer might already include the feature you are looking for.

When you save an image, you can always select whether you want the data to be stored in linear or sRGB format. For example when saving PNGs you can use RGB8_UNORM for linear, or RGB8_SRGB for sRGB formats. In you example you seem to be working with dds or ktx textures I presume? In the bottom left of the PVRTexTool it says "ETC1 Unorm", which means that this image is encoded linear.

However, if it was mistakenly stored in a linear format, and the data should be in sRGB format, you can import that image in the image viewer. Then on the right side, change the equation from 'I0' to 'toSRGB(I0)' (which brightens the image, just like in PVR). And then export it (with the correct format). You can use 'fromSRGB(I0)' for the other direction.

If your concern was that the pixel values in the status bar are displayed 'incorrectly' you can change that via right-clicking the client area -> Pixel Display -> and then changing from 'decimal (linear)' to 'decimal (srgb)' or 'byte (srgb)'.

I hope this helped somewhat. If you have any more questions or I misunderstood the request, feel free to reply

IvanSCP commented 10 months ago

It works, for my ktx texture to write fromSRGB(I0) in the equation. Thanks! 😁