The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: sp3tsnaz on November 22, 2009, 06:40:50 PM

Title: Screen Shot
Post by: sp3tsnaz on November 22, 2009, 06:40:50 PM
hi, im a new member and this is my first post..

I need to take a screen shot in windows xp sp2 or other windows, and save that screen shot to a file .
The first part is easy , i can do that by calling the keyboard event function of the windows api . But the second part is weird , i have not been able to find some solution to it.. Any help is appreciated. Thankyou in advance.

Regards,
Mohsin.
Title: Re: Screen Shot
Post by: 2-Bit Chip on November 22, 2009, 07:53:39 PM
I have attached a procedure that will do the job. It can be used like this:
    invoke GetDesktopWindow
    mov hWndDesktop, eax

    invoke GetWindowImage, hWndDesktop
    mov bitmap, eax
Title: Re: Screen Shot
Post by: baltoro on November 22, 2009, 09:56:02 PM
The code for saving the Desktop to a bitmap file is considerably longer than what 2-bit chip has in his zip, although he starts things out correctly, that code merely pushes the HBITMAP (bitmap handle) to the stack.
Once the BitBlt copies the pixel data to a memory location, you must initialize the BITMAPINFO structure, (this information can be determined by calling GetObject, and passing the HBITMAP). Then typically, you call GetDIBits to retrieve the size of the Pixel data, passing NULL for the BITMAPINFO structure (which returns the size of the pixel data), and dynamically allocate an array to hold the copied pixel data, and call GetDIBits again (with the complete BITMAPINFO structure) to write this data into memory in the native Bitmap format. Finally, you must write the BITMAPHEADER, and then write all that data in the correct sequence to a new file. It's easy to screw it up.
Title: Re: Screen Shot
Post by: Vortex on November 23, 2009, 06:19:37 PM
Hi sp3tsnaz ,

Welcome to the forum.

Saving the desktop to a BMP (http://www.masm32.com/board/index.php?topic=10846.0)