Link to home
Start Free TrialLog in
Avatar of dali
dali

asked on

Manipulating a bitmap's palette for 3D rendering

I'm a beginner with Delphi.

I'm writting a simple 3D rendering program.  I have just finished implementing color shading of objects (Gouraud and Phong) and they both seem to work fine, except for one little snag.  The number of shades for one color is very limited.  Right now, I render the object on a pixel by
pixel basis meaning that the RGB value is calculated for each pixel.  After translating the RGB values to TColor type, I use:
  MyBitmap.Canvas.Pixels[x,y] := <some RGB style number>;

At this point, I believe it is Windows that selects the nearest color in the system palette (or does it come directly out of the bitmap palette... can you tell that I really am not familiar with palettes?? :) and uses IT instead of the calculated color to display on the bitmap.
Now since the system palette does not contain many shades of, let's say blue in my case (I think there were about 4 or 5 in the tested rendered images), the rendered image doesn't look that great.  The moral of this story is: How do I manipulate the system palette (or is it the bitmap palette) to increase the number of shades of a given color? and
furthermore Is there a simple way of having Delphi (or Windows) maximize the use of the palette by selecting appropriate shades?  What units do I need to include?

I fear that the answer to this last part (about maximizing the palette use) is no... if such is the case, are there any libraries available that will do this for me?  (preferably free :)

Even just pointing me to appropriate reading material would be greatly appreciated.  

many many thanks in advance,

Dali
ASKER CERTIFIED SOLUTION
Avatar of mheacock
mheacock

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial