Transparency!! HELP

I have seen some tutorials about this subject, I saw one interesting
but it envolves heavy calculations ( even for a 256 pal ), is there
another way to do this effect without using so many calc. ??

Here's the example i saw, for one color only!!

INITIAL VALUES:
Let: background_RED = 6
       background_GREEN = 78
       background_BLUE = 102

Let: foreground_RED = 90
       foreground_GREEN = 32
       foreground_BLUE = 178

transparency = 0.5 { 0..1 }
error = 65000 { set the error to an impossible value at first }

RGB of transparent color:

     Trans_RED = (background_RED * transparency
                 + foreground_RED * (1-transparency))
     Trans_GREEN = (background_GREEN * transparency
                   + foreground_GREEN * (1-transparency))
     Trans_BLUE = (background_BLUE * transparency
                  + foreground_BLUE * (1-transparency))

Seek nearest color in the pal for transparent color:

for i=0 to 255 do
begin
  how_close =  sqrt((Trans_RED - red[i] * Trans_RED - red[i]) +
                   (Trans_GREEN - green[i] * Trans_GREEN - green[i]) +
                   (Trans_BLUE - blue[i] * Trans_BLUE - blue[i]));

  if(how_close < error) then
    begin
      best_match = i;
      error = how_close;
  end;
end;

I could make a look up table, but isn't there a way of doing this
faster?

Rui Martinho
Faculdade de Cincias de Lisboa -- Informtica
i24...@caravela.di.fc.ul.pt