QA


Q&A

Q1:

Why are color components specified in the range 0 to 255?

A1:

This has to do with the fact that Windows assumes that you are okay with using 8 bits to represent each color component. Allowing 8 bits for each component results in 256 possible shades of that component (0 “255). 8 bits was chosen because 24-bit color is largely considered enough to display extremely high-quality color in graphical images. By combining three 8-bit color components, you arrive at 24-bit graphics. Of course, you might be familiar with the fact that many computers now take advantage of 32-bit color. 32-bit color adds an extra 8-bit channel to a standard 24-bit color to represent the transparency of the resulting pixel. In other words, a 32-bit color consists of three 8-bit color components, as well as an 8-bit value that indicates how transparent (or opaque ) the image pixel is.

Q2:

Why is it necessary to delete graphics objects after creating them when drawing graphics?

A2:

Deleting graphics objects is very important because Windows doesn't inherently know when you are finished using them, and therefore they have a tendency to sit around wasting memory. In fact, undeleted graphics objects represent one of the common memory leaks in Windows programs, which are objects created by a program that are no longer used but still take up memory. Memory leaks are a very bad thing, and should be avoided at all costs. If you stay disciplined about cleaning up after yourself, you shouldn't have too much trouble with graphics objects being inadvertently left in memory.



Sams Teach Yourself Game Programming in 24 Hours
Sams Teach Yourself Game Programming in 24 Hours
ISBN: 067232461X
EAN: 2147483647
Year: 2002
Pages: 271

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net