News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Handling bitmaps

Started by Vortex, May 29, 2018, 04:29:54 AM

Previous topic - Next topic

Vortex

Here is a console application saving the desktop to a bitmap file. No any COM or GDI+ techniques and just plain API.

Steps to save the desktop to a bitmap :

- Get the width and height of the desktop
- Get the device context ( DC ) of the desktop and create a compatible DC
- Create a compatible bitmap.
- Copy the image to the new DC.
- Fill the BITMAPINFOHEADER and BITMAPFILEHEADER structures.
- Get the bits of the bitmap to be saved to disc.
- Save the bitmap structures and color data to disc.

Usage :

SaveDesktop.exe test.bmp

The default bit depth is 24.

Any third parameter to set the bit depth to 32 :

SaveDesktop.exe test2.bmp 32

felipe

 :greenclp: This is great! I was wishing to have an app to make snapshots of my desktop, but i didn't wanted bloatware! You are a genius, thanks for sharing this!  :biggrin:


zedd151

It works well.... however, when I run it from a batch file it captures the command window in front of the intended target.
How would one run the program and avoid such instances?

felipe

Open a cmd, put it in a corner of the screen and then run the program (using the options needed)  :idea:

This program is also very useful to play a little pranks to my girl (who knows little about PCs...) When the .bmp is full sized you can move the mouse above of the image but nothing seems to work when you do clicks on the icons!  :badgrin:

zedd151

#4
Here is what it looks like using "run" instead of the cmd prompt. (converted it to .gif to reduce filesize)

Perhaps if you included a timer into the mix to allow closing the command window.....   ;)
But other than that I think it's a great little program.

I think if the timer was added, it could be a production-ready, commercially viable program.    :biggrin:

hutch--

Trick is with screen capture is to hide the calling app first, grab the screen then show the caller again.

felipe

This is what i get when i simple resize the command line (cmd.exe). Sorry for the big image Hutch you can delete this later...

zedd151

Quote from: hutch-- on May 29, 2018, 12:31:17 PM
...hide the calling app first, grab the screen then show the caller again.

Sounds like you've done that before.  :t

A slight delay in the capture could also allow the caller to close. A few milliseconds should be plenty.  :bgrin:
I might just try to do that myself.... (but 32 bit...)


@ felipe...
but the cmd window still muddies up an otherwise good screen capture. That was my whole point. 




zedd151

Or possibly add a little code to check when the calling program closes.
just after closing the command window for instance, the screen capture would take place.

Of course if a timer were use, it could lead to recording an animation of sorts. Possibly for software demo??   :idea:

This topic is bringing so many possibilities to mind.

felipe

Quote from: zedd151 on May 29, 2018, 12:36:54 PM
@ felipe...
but the cmd window still muddies up an otherwise good screen capture. That was my whole point.

Well, you know how it is, you can't satisfy to all... ;)

But it surely wholes my needs of screenshots  :icon14:. If i will have to choose (actually i already did  :biggrin:) between this nice assembly program and some bloatware...guess what... :idea:

zedd151

Quote from: felipe on May 29, 2018, 12:46:31 PM
If i will have to choose (actually i already did  :biggrin:) between this nice assembly program and some bloatware...guess what... :idea:

Oh, you are so right about that.   :t 

Such a simple little program is more than sufficient. Good job, Vortex.

Vortex

Thanks for the feedback. The console window is now hidden while capturing the screen :

invoke  GetConsoleWindow
mov     hwnd,rax
invoke  ShowWindow,rax,SW_HIDE
invoke  Sleep,300
.
.
.
invoke  ShowWindow,hwnd,SW_SHOW
ret


New upload at the top.

felipe


Vortex

Hi felipe,

About your image : sorry, if you encountered a problem could you please help me to reproduce the issue? Thanks.

felipe

I don't understand vortex, i have found no problems...You mean in the future?  :idea: