1. palette stuff again
- Posted by Lewis Townsend <keroltarr at HOTMAIL.COM> Oct 13, 1998
- 541 views
David, I tried your convertToPalette () function and I couldn't get it to work the way that I wanted. I changed my function to call yours and actually change the picture to use the standard palette. Here's what I'm doing; tell me if I'm totally doing something wrong or if this just doesnt work in graphics_mode (18). global function new_pal (sequence pal_n_pic) -- this function makes a bitmap work with the standard palette -- call this function BEFORE you call all_palette object index, pic pic = pal_n_pic [2] index = convertToPalette (pal_n_pic [1]) -- giving visual aid to what's happening position (1,1) puts (1, "Converting bitmap to normal palette:\n[" & repeat (' ', length(pic [1])+1) & "]") position (2,2) for x = 1 to length (pic) do if integer (x) then puts (1, "#") end if for y = 1 to length (pic [x]) do pic [x] [y] = find (pic [x] [y], index) -1 end for end for puts (1, "\n Complete, thank you for waiting") return {get_all_palette (), pic} end function TIA Lewis Townsend ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
2. Re: palette stuff again
- Posted by "Cuny, David" <David.Cuny at DSS.CA.GOV> Oct 13, 1998
- 544 views
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
3. Re: palette stuff again
- Posted by Lewis Townsend <keroltarr at HOTMAIL.COM> Oct 13, 1998
- 543 views
Thanks again David, That works except that my image was two dimensional so instead of: >for i = 1 to length( image ) do > image[i] = change[ image[i]+1 ] >end for I had to do something more like this for x = 1 to length (pic) do for y = 1 to length (pic [x]) do pic [x] [y] = index [pic [x] [y] + 1] end for end for The routine couldn't find matches for bright_cyan, orange, yellow, and white. The bright red color was changed to a darker red. However it's a heck of alot better than what I had before! thanks again, Lewis Townsend ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com