Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • Last Modified:

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
0
dali
Asked:
dali
1 Solution
 
mheacockCommented:
I would suggest getting a good API book.  The Win32 API Bible by the Waite Press has an excellent palette section.  It will tell you how to make a palette...you can then assign this palette you make to the palette of your form's canvas...Delphi will then handle the rest of the palette relaizations and such.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now