Re: difference between two colors

new topic     » goto parent     » topic index » view thread      » older message » newer message

Tone Skoda wrote:

> Can anyone think of any better function
> to get difference between two colors.

The code in Dos32Lib does something similar to map the colors in a Euphoria
bitmap to the best fit in the current palette. It seemed to work just fine
with just comparing the difference of rgb. Essentially just a pared-down
version of what you're proposing:

   best = #FFFFFF
   index = 0
   -- examine each option
   for i = 1 to length options do
      -- get difference for each rgb
      for j = 1 to 3
         diff += abs( color[j] - option[i][j] )
      end for
      if diff < best then
         index = i
         best = diff
      end if
   end for

-- David Cuny

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu