1. Palette Problem
- Posted by Gwena=?ISO-8859-1?Q?=EBl?= Joret <mb11363 at TVD.BE> May 13, 1999
- 459 views
Hi All! I've a little problem using palette in Eu using Read_bitmpap() : How to Change a palette of a Bmp ? : I want to use only one palette but my Bmps don't have the same pal, And I don't know how to display 2 Bmp with differents pals at the same time on Screen. Can you help me a bit please ? Gwen
2. Re: Palette Problem
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> May 13, 1999
- 445 views
> I've a little problem using palette in Eu using Read_bitmpap() : How > to Change a palette of a Bmp ? : > I want to use only one palette but my Bmps don't have the same pal, And I > don't know how to display 2 Bmp with differents pals at the same time on > Screen. Can you help me a bit please ? There are a number of possible 'solutions' .. I'll list them all: * Match the associated rgb-value (in the palette) of pic 1 with those found in pic 2 and change the color-index-values in one the two pictures accordingly. * Use a true-color video mode * Download paintbrush pro or some other image program and have it match the palettes for you * Use a good graphics library that matches such indexes for you. The first can be done using any of the few libraries available for this. (I can remember one by Lucius Hilley, am not sure though) The second can be done by Neil (Pete's), and in theory you _could_ use TrueEU (Hawke's / Christopher-Street). (but then again, I can also go around jumping around in my room with a shoe in my mouth .. .. yet I suggest Neil anyway. The third: go to http://www.jasc.com The fourth: Neil again. (when in an palette mode, it matches new loaded pictures with the current palette automatically) Ralf N.
3. Re: Palette Problem
- Posted by Colin Taylor <cetaylor at COMPUSERVE.COM> May 13, 1999
- 435 views
Message text written by Gwen: >I've a little problem using palette in Eu using Read_bitmpap() : How to Change a palette of a Bmp ? : I want to use only one palette but my Bmps don't have the same pal, And I= don't know how to display 2 Bmp with differents pals at the same time on Screen. Can you help me a bit please ?< Only one palette can be active, so if you try to show two images with different palettes at the same time, the colors of one will be wrong. Th= e easiest solution is to convert one image to the palette of the other. I wrote some palette utilities for just this purpose, which are posted on t= he RDS web page (recent contributions). HTH. Colin
4. Re: Palette Problem
- Posted by Lucius Hilley III <lhilley at CDC.NET> May 13, 1999
- 448 views
Hello Colin: This is Lucius, Remapping palettes does work great MOST of the time but after working with several images I have found several problems with it. 1. If it does work and work well you would want to save a copy of the image with the new palette. Remapping on the fly is a little slow. 2. 1 reason it may not work is that you have an image that has abundance of 1 color in the palette. Example: an image of Lava would have a palette consumed with different shades of red. And an image of the sky would have many blues. These 2 images won't simply remap very well from their palette to the others palette. You may have to Build a new palette that is a partial mixture of the 2 and remap both images to it. 3. I doubt Colin took this into account but I may be wrong. I know I took it into account when writing my rountines and gave up before solving the problem of drastically different palettes. I think Pete Eberlein wrote some excellent routines in this area. NOT SURE. Lucius L. Hilley III On Thu, 13 May 1999 10:24:43 -0400, Colin Taylor <cetaylor at COMPUSERVE.COM> wrote: >Message text written by Gwen: >>I've a little problem using palette in Eu using Read_bitmpap() : How >to Change a palette of a Bmp ? : >I want to use only one palette but my Bmps don't have the same pal, And I >don't know how to display 2 Bmp with differents pals at the same time on >Screen. Can you help me a bit please ?< > >Only one palette can be active, so if you try to show two images with >different palettes at the same time, the colors of one will be wrong. The >easiest solution is to convert one image to the palette of the other. I >wrote some palette utilities for just this purpose, which are posted on the >RDS web page (recent contributions). HTH. > >Colin
5. Re: Palette Problem
- Posted by David Cuny <dcuny at LANSET.COM> May 13, 1999
- 470 views
Gwenakl Joret wrote: >I've a little problem using palette in Eu using Read_bitmpap() : How >to Change a palette of a Bmp ? : The routine readBitmapFromFile() returns the bitmap portion (or an error code) of the requested bitmap. It reads the requested bitmap, then maps the bitmap's palette to the current palette. Finally, it replaces the references in the bitmap from it's original pal to the current pal. Some obvious points: 1. You need to set the graphics_mode before calling the function. 2. Resolutions with more colors take longer to convert 3. It works in all graphics modes, but higher modes have more colors, so map better To speed things up, I can suggest the following: 1. Pete has an assembly version of this on his home page - runs faster! 2. Reduce the colors in the bitmap you are reading, if you can. 3. If you always use the same bitmaps, map them all to the same palette: - read all the bitmaps mapped to the same palette - save the bitmaps with the new palette Once they are converted over, you can use the regular Euphoria tools again. Hope this helps! -- David Cuny include image.e procedure abortErr( sequence msg, sequence args ) -- display an error message and abort printf( 1, msg, args ) abort( 0 ) end procedure function abs( atom a ) -- return absolute value if a > 0 then return a else return -a end if end function function convertToPalette( sequence sourcePal ) -- convert the color list to palette indexes atom err, diff, best sequence destPal, colorIndex -- get palette destPal = get_all_palette() -- adjust source sourcePal = floor( sourcePal/4 ) -- build holder for results colorIndex = repeat( 0, length( sourcePal ) ) -- look at each entry for i = 1 to length( sourcePal ) do -- set the last best match as impossibly bad best = #FFFFFF -- look through the palette for entry = 1 to length( destPal ) do -- error amount for this entry err = 0 -- for each {rgb} for rgb = 1 to 3 do -- error is difference between the two diff = abs( sourcePal[i][rgb] - destPal[entry][rgb] ) err = err + diff end for -- better match than prior best match? if err < best then -- save error amount best = err -- store the palette index colorIndex[i] = entry end if end for end for return colorIndex end function function readBitmapFromFile( sequence fName ) -- load a bitmap from the current file, and map to current palette integer index sequence replace object res -- attempt to read bitmap res = read_bitmap( fName ) if integer( res ) then -- return the error message return res end if -- adjust the current palette replace = convertToPalette(res[1]) -- replace values with references to new palette for i = 1 to length( res[2] ) do for j = 1 to length( res[2][i] ) do -- get index index = res[2][i][j] -- get actual color index = replace[index+1]-1 -- replace res[2][i][j] = index end for end for -- return bitmap return res[2] end function
6. Re: Palette Problem
- Posted by Colin Taylor <cetaylor at COMPUSERVE.COM> May 13, 1999
- 448 views
Message text written by Lucius: >Hello Colin: This is Lucius, Remapping palettes does work great MOST of the time bu= t after working with several images I have found several problems with it. 1. If it does work and work well you would want to save a copy of the ima= ge with the new palette. Remapping on the fly is a little slow. 2. 1 reason it may not work is that you have an image that has abundance = of 1 color in the palette. Example: an image of Lava would have a palette= consumed with different shades of red. And an image of the sky would have many blues. These 2 images won't simply remap very well from the= ir palette to the others palette. You may have to Build a new palette th= at is a partial mixture of the 2 and remap both images to it. 3. I doubt Colin took this into account but I may be wrong. I know I too= k it into account when writing my rountines and gave up before solving the problem of drastically different palettes. I think Pete Eberlein wrote some excellent routines in this area. NOT SURE. Lucius L. Hilley III < If the palettes are very different, both images can be remapped to a comm= on palette such as a windoze or web palette or even a mac palette. Remappin= g on the fly is very fast for small images. For better-looking results, th= e images can be dithered to a new palette which is also fairly fast (usuall= y less tha 1 second for a 320x240 image on my machine). Colin
7. Re: Palette Problem
- Posted by Gwena=?ISO-8859-1?Q?=EBl?= Joret <mb11363 at TVD.BE> May 14, 1999
- 438 views
Hi all I tried a lot of functions to remap a palette, it works quite well ! Thanx for your help ! (Unfortunaly I need among other things to remap a clouds pic --> palette is almost blue Gwen