SetPixel / GetDIBits issue

Hey hey,

Im trying to use some old code to capture the screen, store it in a buffer, and then use SetPixel to show what it captured, just for testing

Now, its failing very hard, this is the code: http://pastebin.org/762024
And this is the result of executing it: http://i38.tinypic.com/efs9zt.png

I read about some issues with SetPixel on vista, im running 7, so maybe its fixed, i dunno
If theres a bug in my code please tell me how to fix it, and if it works on your computer and its a bug from windows, then.. i have a problem :P
Last edited on
Mystery solved.

It works fine on my other laptop..

Now to fix this issue with 7
Last edited on
I wouldn't call it "mystery solved" if the problem is still there.
Note that each scan line is aligned on a 4-byte boundary. If necessary, padding bytes are added at the end of each line, so you need to skip those.
Thanks, i read alot of stuff about SetPixel failing if windows aero is off, its not SetPixel, i tested some stuff with it and it worked fine,

The code has always worked for me on my old laptop, i guess it had the resolution so that the padding was 0..
But how do i make my code so that itll work with this boundary/padding?

Edit:

Fixed it!

Added this to the RGB functions:
return Data[y*(X*3+((X*3)%4))+3*x+ ];
And Data is a bit bigger in size:
BYTE* Data = new unsigned char[Y*(X*3+((X*3)%4))];

Obviously (X*3)%4 is the padding..
It works perfect now, thanks again!
Last edited on
Topic archived. No new replies allowed.