• Advertisement

Archived

This topic is now archived and is closed to further replies.

Guest Anonymous Poster

Convert a 16-Bit-OffScreen-Surface into GrayScale?

This topic is 6733 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

there are several methods of grayscaling colors, the one i present here will make most things still easy to differentiate.

first, you deconstruct the pixel into its R, G, and B

if in 565, divide the G component by two, so that everything is from 0 to 31

grayscaling is done simply by weighting the colors by percentages.

a good weight to use is:

Blue: 11%
Green: 59%
Red: 30%

so, now calculate:

NewRGB=(b*11+g*59+r*30)/100;

use this new value as the new red, green, and blue components (if in 565, multiply by 2 for green)

now reconstruct the pixel from these RGB values, and put the pixel

if you want a "yellowed paper" or "antique" look, multiply the blue by 7/8 or 3/4 (or whatever fraction you like, based on your preference)

you can also get a nice "smudge" or blurring effect by taking some areas and apply an anti-aliasing algorithm between every other pixel.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Thanks, but I only know the Blt() to copy something in a surface. So I change my Question How can I read one Pixel from a Surface and get the color? Is there a funktion like Getpixel in Pascal?

Share this post


Link to post
Share on other sites
if individual pixels are the things you want to do, then i suggest you look up the following member functions of IDirectDrawSurface:

(if you want "direct" memory access to the surface)
Lock()
Unlock()

(or, if you want the slower GDI route)
GetDC()
ReleaseDC()

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
How can I do it in DirectDraw? Is there a function?
I want to make a treasure-map, which I blit from an other OffScreen-surface and it should look old and not in 65000 colors.
Thanks for your help

Share this post


Link to post
Share on other sites

  • Advertisement