Painting on indexed images by index
Operating System: any
Description of the feature
Currently when painting on an indexed image, GIMP converts your colors to one of the colormap colors (using the "closer" one when your FG/BG are not within the colormap), and would in the end convert it back to the corresponding index.
A problem occurs when you have several indexes with the same color (a case raised in #3041 (closed)). This may seem weird, but makes total sense when you think about it.
Currently we can edit such images by modifying the color in the colormap. But we cannot create new pixels of the higher index with same color.
Say you draw a character with a hat and shoes using flat colors (separate index). At some point, you may try to set them at the same color, but it doesn't mean you want to merge the indexes. You still want to keep them as separate indexes (and have the choice to later change color for only one item).
Or whatever other use case. :-)
- Create 2 indexes in your colormap with exactly the same color. For instance index 1 and 2 (index 0 has the background).
- Click on index 2 in the colormap.
- Draw on the canvas.
- Double click index 2 to edit the color and set it to something else.
Expected result: your recently drawn pixels should change colors.
Actual result: nothing happens, because the pixels were actually set to index 1. You can never draw anything as index 2 (unless you temporarily change it to be its own unique color, then switch back to be the same as index 1 afterwards).
Looking at the code, the problem seems to be that we just always draw with RGBA data which we convert to the image's palette (hence it takes a random color if several matches). It would be very useful to only do so when the foreground color has been selected as RGB, but not when it was selected directly from the colormap. Then we should use it as an index directly.