# Plotting a pixel with DDraw

Hi,
I'm a very beginning DirectDraw programmer
I want to know how to plot a pixel with
DirectDraw, and maybe some example source code
Thanks!
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
1:Lock the surface
2:Do pixel
3:UnLock the surface

Continue

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
// Lock the primary surface
if FAILED( lpDDSPrimary->Lock( NULL, &ddsd, DDLOCK_WAIT , NULL ) )
{
return Fail( hwnd, "Couldn't lock the primary surface.\n" );
}

// Clear it to white
// We are assuming: 1) we are palettized, so each
// pixel is represented by a "byte" and 2) since we are not setting
// a new palette, entry 255 should be white.
dest = (BYTE *)ddsd.lpSurface;
for ( y = 0; y < ( int )ddsd.dwHeight; y++ )
{
for ( x = 0; x < (( int )ddsd.dwWidth ); x++ )
{
dest[x] = 0xFF;
}
// lPitch contains the pitch in *bytes*
dest += ddsd.lPitch;
}

// Unlock the primary surface
if FAILED( lpDDSPrimary->Unlock( NULL ) )
{
return Fail( hwnd, "Couldn't unlock the primary surface.\n" );
}

This is the way to white a 256-color surface.But if you in 16bit,you need first get the formate,I mean 5-6-5 or other combination ,then You can do the same.
Regards.
Wyn

###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.