I think I found something strange with FreeImage_SwapColors.
If I have a pallete with these values [blue, red, green, yellow, orange]
and use FreeImage_SwapColors(dib, &pal[0], &pal[3], TRUE), the result is [yellow, red, green, yellow, orange] and not [yellow, red, green, blue, orange]
Looking at FreeImage_ApplyColorMapping source code made me think the swap is similar to
srccolor = dstcolor
dstcolor = srccolor
related to misuse of pointers which, obviously, doesn't work.
FreeImage_SwapColors expect 2 RGBQUADs pointers on entry but also expect that these pointers have no link with the palette array (also true for FreeImage_ApplyColorMapping).
That's why your test case doesn't work.
We could add a check for pointers and handle your use case, or explicitly document the fact that input RGBQUADs parameters should have no link with the palette array.
Hervé
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I think I found something strange with FreeImage_SwapColors.
If I have a pallete with these values [blue, red, green, yellow, orange]
and use FreeImage_SwapColors(dib, &pal[0], &pal[3], TRUE), the result is
[yellow, red, green, yellow, orange] and not
[yellow, red, green, blue, orange]
Looking at FreeImage_ApplyColorMapping source code made me think the swap is similar to
srccolor = dstcolor
dstcolor = srccolor
related to misuse of pointers which, obviously, doesn't work.
So I had to made the swap myself with
hope this will help to fix this issue
OF course, if I missed something, just tell me and forgive me ;)
KanedaFr
Hi,
FreeImage_SwapColors expect 2 RGBQUADs pointers on entry but also expect that these pointers have no link with the palette array (also true for FreeImage_ApplyColorMapping).
That's why your test case doesn't work.
We could add a check for pointers and handle your use case, or explicitly document the fact that input RGBQUADs parameters should have no link with the palette array.
Hervé