Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Manipulating a bitmap's palette for 3D rendering

Posted on 1997-03-25
1
Medium Priority
?
330 Views
Last Modified: 2013-12-03
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
Comment
Question by:dali
1 Comment
 
LVL 3

Accepted Solution

by:
mheacock earned 100 total points
ID: 1334948
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question