Solved

Manipulating a bitmap's palette for 3D rendering

Posted on 1997-03-25
1
321 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 50 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now