Click here to Skip to main content
15,888,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need help drawing and shading pixels with gdi32 and c++. Can anybody help?
Posted
Updated 22-Mar-11 6:57am
v2
Comments
mbue 22-Mar-11 13:34pm    
Where do you want to paint to? Bitmap or Screen (HDC)? You can paint shaded pixels only if you have the pixel beneath (i.e. to a bitmap).
Regards.
Sandeep Mewara 22-Mar-11 17:26pm    
What kind of help you are looking for? Until you share what have you done and where are you stuck, it would be difficult for members to comment.
Richard MacCutchan 22-Mar-11 17:39pm    
Try a Google search for "GDI Draw", you will find lots of samples.

1 solution

Here's a thought
C++
#define RGB_GETBLUE(rgb)  (((rgb) >> 16) & 0xff)
#define RGB_GETGREEN(rgb) (((rgb) >> 8) & 0xff)
#define RGB_GETRED(rgb)   ((rgb) & 0xff)

COLORREF pix = ::GetPixel(hDC, x, y);

int red   = RGB_GETRED(pix);
int green = RGB_GETGREEN(pix);
int blue  = RGB_GETBLUE(pix);

float shadowEffect = 0.5f;

red   = static_cast<int>(red * shadowEffect);
green = static_cast<int>(green * shadowEffect);
blue  = static_cast<int>(blue * shadowEffect);

::SetPixel(hDC, x, y, RGB(red, green, blue));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900