Original Post
Ok, so nearly two years ago I posted this thread I finally got around to playing with the Managed DirectDraw stuff again, & figured how to do this. And yes, I know ddraw has been depreciated.
/*
...do some stuff...
initialize DirectDraw & create surfaces
...do more stuff...
*/
/*a GraphicsStream, which we write to in order manipulate pixels*/
Ddraw.LockedData BackBuffer;
/*holds the x,y poisition of the pixel*/
int x = 10;
int y = 10;
/*couldn't written my own, but since it's already here...*/
System.Drawing.Color color = System.Drawing.Color.Green;
/*Lock(...) gives us access to the screen data. Wait until we can lock it*/
BackBuffer = SecondarySurface.Lock(Ddraw.LockFlags.Wait);
/*Similar to how we'd calculate the arrary index back in c for the surface memory*/
BackBuffer.Data.Seek(y * BackBuffer.Pitch + x * (BackBuffer.RGBBitCount / 8), System.IO.SeekOrigin.Current);
/*this is assuming 32bit color, so pass the color data as a byte array
Blue, Green, Red, Alpha*/
byte[] pixelData = {color.B, color.G, color.R, 0};
BackBuffer.Data.Write(pixelData);
/*all done*/
SecondarySurface.Unlock();