TIMP transfer with non black color zero

Door Metalion

Paladin (1008)

afbeelding van Metalion

14-01-2019, 10:41

Hi everyone,

I need to transfer a 16x16 tile using a TIMP logical operator BUT the color zero is the white color in my palette, and I need to preserve that color in the result. A simple TIMP transfer won't do, since with that operator :
if SC=0 then DC=DC else DC=SC

I thought of making first an AND logical transfer and then a TIMP one. The first AND command would transfer the white color (since any color AND 0 would result in 0), and the second TIMP command would transfer the rest of the colors except the white.

The only problem is that with that solution I need to have two different backgrounds. A background color 'F' for the AND command (to preserve all colors in the result), and a background color '0' for the TIMP transfer (for the same reason). I do not have the space for doubling the tiles in VRAM, so that's not a viable solution.

Apart from redefining the 0 color (which I have already considered, but it's a real pain in the ass), do you see a simpler solution ?

Thanks.

Aangemeld of registreer om reacties te plaatsen

Van Grauw

Ascended (8455)

afbeelding van Grauw

14-01-2019, 11:37

If colour 15 is transparent, you can invert all source pixels and use TNOT rather than TIMP.

Alternatively, you could XOR the source image with the transparent colour index, then LMMM TIMP copy from the source to the destination, and then HMMV TXOR the destination with a mask texture using 0 for the transparent and the transparent colour index for the opaque pixels.

But to be honest I would probably prefer redefining colour 0 to be the transparent one.

Van Metalion

Paladin (1008)

afbeelding van Metalion

14-01-2019, 12:56

Grauw wrote:

If colour 15 is transparent, you can invert all source pixels and use TNOT rather than TIMP

Yes !! That's the solution.
Thank you Grauw
Smile

Van Metalion

Paladin (1008)

afbeelding van Metalion

20-01-2019, 18:20

In the end, I had to do differently because I wanted to keep the black also, which was in color #15. So, for future reference, I ended up doing this, using color #4 as the transparent one :

. storage of source XORed with 4
. LMMV destination with color #4, logical operator XOR
. LMMM source to destination, logical operator TIMP
. LMMV result with color #4, logical operator XOR

Van Manel46

Champion (431)

afbeelding van Manel46

20-01-2019, 19:12

Only one comment:
Gimp allows you to change the order of the colors, so you can easily handle this situation. The color 0 is that of the background, which becomes transparent with the logical function.