Re: palette stuff again

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

Hi, Lewis.

convertToPalette generates sequence of what to replace the color indexes by.
Remember that the first item in the sequence is at index zero, not one. So
if convertToPalette returned a sequence like this:

        { 1,0,2 }

It means:

   change palette color reference from    into
   -----------------------------------    ----
   0                                      1
   1                                      0
   2                                      2

So the code should be something like this:

-------------------------------------
sequence bmp, pal, image, change

-- read the bitmap
bmp = read_bitmap( "foo.bmp" )

-- separate into pal and image
pal = bmp[1]
image = bmp[2]

-- determine the replacement colors
change = convertToPalette (pal)

-- replace the image indexes with new indexes
for i = 1 to length( image ) do
   image[i] = change[ image[i]+1 ]
end for

-------------------------------------

Hope this helps!

-- David Cuny

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

Search



Quick Links

User menu

Not signed in.

Misc Menu