flat assembler
Message board for the users of flat assembler.

Index > Windows > gdi, get screenshot problem

Author
Thread Post new topic Reply to topic
sleepsleep



Joined: 05 Oct 2006
Posts: 8902
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
hi there Smile
i was trying to make an application that could take desktop screenshot.
i code the thing in DLL (so that i or other could simply link to it and using it later).

although i successfully get the screenshot in bmp format, but* i wonder why it doesn't cover the whole desktop screen Sad Sad

i only got a 240x800 px image but my desktop is 800x600 px. Sad don't know where went wrong.

plez take a look at the below (maybe u could just copy and assemble it)

my files tab at 6
the dll core.
Code:
check below for updated thingy
    


console application to take screenshot upon init.
Code:
check below for updated thingy
    


Last edited by sleepsleep on 19 Mar 2007, 11:16; edited 1 time in total
Post 17 Mar 2007, 05:36
View user's profile Send private message Reply with quote
Mr_Silent



Joined: 25 Apr 2006
Posts: 30
Mr_Silent
HORZRES = 8
VERTRES = 10
Post 17 Mar 2007, 07:46
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8902
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
lol @ myself Smile
thanks mr_silent

i think i got that value from google... without aware that it is not for windows Wink Laughing Laughing Laughing
http://www.google.com/search?client=opera&rls=en&q=define+HORZRES&sourceid=opera&ie=utf-8&oe=utf-8

maybe somebody could check if i leak any gdi resource or not Arrow Embarassed
Post 17 Mar 2007, 07:56
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8902
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
okie, i reupdate this code and make it a nice dll that able to be called from vb, (or etc language as u wish)

file tabbed at 7

to use it from visual basic, just assembled the DLL then use the below code.
Code:
Private Declare Sub scan_window Lib "dscanner.dll" ()
Private Declare Sub set_bmpFileName Lib "dscanner.dll" (ByVal bmpFileName As String)
Private Declare Sub set_scwH Lib "dscanner.dll" (ByVal windowhandle As Long)

Private Sub Command1_Click()
    Dim k As String
    k = Text1.Text
    Call set_bmpFileName(k)
    Call set_scwH(Val(Text2.Text))
    Call scan_window
End Sub
    


Image


Description: sample win32 console app to test the dll
Download
Filename: k.txt
Filesize: 673 Bytes
Downloaded: 57 Time(s)

Description: the dll code, tabbed 7
assembled without problem with fasm released March 11, 2007

Download
Filename: dscanner.txt
Filesize: 3.06 KB
Downloaded: 73 Time(s)

Post 19 Mar 2007, 11:15
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
sleepsleep: sorry, but i must repeate my favourite one:

YOU SHOULD CHECK RETURN VALUES OF API CALLS!!!!!

Smile
Post 19 Mar 2007, 12:12
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
Ok, the first of all - i like it)
then corrections & suggestions
Code:
format PE GUI DLL AT 500000h
    

To avoid automatic reallocation of base.
Code:
bmpFileHeader   BITMAPFILEHEADER 'BM',0,0,0,sizeof.BITMAPFILEHEADER + sizeof.BITMAPINFOHEADER
    

It is more understandable
Code:
bmpFileName     rb MAX_PATH
    

MAX_PATH is defined in win headers (=260)
Code:
bmpInfo         BITMAPINFOHEADER sizeof.BITMAPINFOHEADER,0,0,1,24,BI_RGB,0,0,0,0,0
                        rd 6  ;;WHAT IS IT FOR?WHY 6?
    

Setting the bfSize in BITMAPFILEHEADER
Code:
                mov     eax,[scwHeight]
                imul    eax,[scwWidth]
                imul    eax,3
                mov     [bmpSize],eax
                lea     edx,[eax+sizeof.BITMAPFILEHEADER+sizeof.BITMAPINFOHEADER]
                mov     [bmpFileHeader.bfSize],edx
    

its enough for a while;)

_________________
Any offers?
Post 19 Mar 2007, 12:44
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8902
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
thanks a lot Wink
vid & asmfan Razz comments appreciated !! Smile
Post 19 Mar 2007, 16:15
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
looking forward for newer version. This could make nice example if fixed
Post 19 Mar 2007, 16:24
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.