Searge-DP / grafx2

Automatically exported from code.google.com/p/grafx2
0 stars 0 forks source link

Colormap effect #458

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I was thinking of a new effect that would use a 256x256 array:
output_color = colormap[brush_color][image_color]

A classic usage would be as a super-fast transparency effect when the array is 
computed according to the palette and the transparency % setting.
But the original computation is very expensive and there are many things that 
can change the palette, so I don't think it's viable to recompute the table 
automatically.
The table could be computed by script, allowing a large number of effects.
This idea still needs a lot of thinking, especially since it's a rather rough 
and technical tool, not evident for the user.

I attach here the code I wrote to quickly compute the transparency table : it's 
optimized to gain time when palette has many identical colors (for example when 
unused palette entries are "zapped" to the same rgb values).

Original issue reported on code.google.com by yrizoud on 20 Oct 2011 at 10:01

Attachments:

GoogleCodeExporter commented 8 years ago
The algorithm is slow because we still have no fast way to map (R,G,B) to color 
index. It could be done with an octree, for example. This would also help a lot 
with the median cut algorithm for color reduction, as well as making such a 
table updated realtime possible.

Also, I'd use "if (same_as[color2]<color2)" instead of "if 
(same_as[color2]!=color2)". Doesn't change the result, but reads more easily 
for me.

Original comment by PLumeArg...@gmail.com on 24 Oct 2011 at 7:57