News:

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

Main Menu

BitBlt And CPU 100%

Started by Fraile, April 23, 2014, 06:38:28 AM

Previous topic - Next topic

qWord

Why is HWND_BROADCAST used? This produce useless message processing in all GUI threads except the thread of the actual target window.
For WM_PAINT I would pool the paint requests over a specific time interval and then copy the corresponding screen region.
MREAL macros - when you need floating point arithmetic while assembling!

Fraile

Hi, good night from southern Spain.

My program used the hook for see if there change of the screen. If there change ("WM_PAINT" , "WM_KEYDOWN" And "WM_MOUSEMOVE"), sent a message for capture to the all screen.

I use "HWND_BROADCAST " . Fails to reach the message specifying the handler my thread. I've tried "invoke PostMessage, HwndMyThread, HwdMensaje,0,0" but doesn't  work.

My hook is only a jumper for capture to the screen.

Farabi, MichaelW and Qword, tell me limit the frequency of an event ("WM_PAINT", "WM_KEYDOWN" Y "WM_MOUSEMOVE"),  for reducing  the use CPU. I dont know how  limit the frequency??.

Another example, please?

Other way, please?

qWord

Can you please give us some more details about your intention? Why do you need to write a program for remote control in Assembler?
MREAL macros - when you need floating point arithmetic while assembling!

MichaelW

#18
Edit: Finished the example :lol:

;==============================================================================
    include \masm32\include\masm32rt.inc
;==============================================================================
    .data
          pc_frequency  dq 0
          pc_count      dq 0
          r8            REAL8 ?
          hTimer        HANDLE 0
          msg           MSG <>
    .code
;==============================================================================
TimerProc proc hwnd:HWND, uMsg:UINT, idEvent:DWORD, dwTime:DWORD
    ;---------------------------------------------------
    ; On the first call initialize pc_count and return.
    ;---------------------------------------------------
    mov eax, DWORD PTR pc_count
    or  eax, DWORD PTR pc_count+4
    jnz @F
    invoke QueryPerformanceCounter, ADDR pc_count
    ret
  @@:
    ;---------------------------------------------------------------
    ; Calc and display the elapsed seconds since the previous call.
    ;---------------------------------------------------------------
    fild pc_count
    invoke QueryPerformanceCounter, ADDR pc_count
    fild pc_count
    fsubr
    fild pc_frequency
    fdiv
    fstp  r8
    printf("%f\n", r8)
    ret
TimerProc endp
;==============================================================================
start:
;==============================================================================
    invoke QueryPerformanceFrequency, ADDR pc_frequency
    printf("%I64d\n", pc_frequency)
    invoke SetTimer, 0, 0, 1000, ADDR TimerProc
    push eax
    ;-------------------------------------------------
    ; For this type of timer to work in a console app
    ; the calling thread must dispatch messages.
    ;-------------------------------------------------
  @@:
    invoke GetMessage, ADDR msg, NULL, 0, 0
    invoke DispatchMessage, ADDR msg
    invoke GetAsyncKeyState, VK_ESCAPE
    test eax, 1
    jz  @B
    pop eax
    invoke KillTimer, 0, eax
    inkey "Press any key to exit..."
    exit
;==============================================================================
end start


3579545
1.001420
1.001432
1.001438
1.001461
1.001426
1.001437
1.001436
1.001504
1.001374
1.001440
1.001449
1.001435
1.001436
1.001443


QuoteMy program used the hook for see if there change of the screen. If there change ("WM_PAINT" , "WM_KEYDOWN" And "WM_MOUSEMOVE"), sent a message for capture to the all screen.

Why do you need to capture every change in the screen?

Well Microsoft, here's another nice mess you've gotten us into.

Fraile

Yes, my intention is to create a program to view multiple PCs remotely.

Attached Demo.

Config.INI:

ip=192.168.1.197 (Ip Server)
puerto=8889        (Port)
tipocursor=0         (1 = BitBlt with CAPTUREBLT Or SRCCOPY. 0 = BitBlt only SRCCOPY)
modo=1               (1 = Server. 0 = Client)
coldivpantalla=1  (Columns split screen)
fildivpantalla=1    (Rows split screen)
tipoenvio=1         (Send)
tipoimg = 0          (0 = type image JPG. 1 = type image BMP)

The program still did not work well. Is a prototype.
Is only for 32bits.
On some computers the CPU is high.
The program only send images, when GPS.DLL (hook) see a change.



Fraile

MichaelW, thanks for the example, I now understand the function "QueryPerformanceFrequency"



Fraile

Hi,

This is correct, for calculate the time (miliseconds) it takes my function in  screen capture?

Code:

.Data

pc_frequency   DQ 0
IniTime           DQ 0
FinTime           DQ 0


.Code
.
.

                        Invoke QueryPerformanceFrequency, Addr pc_frequency
                        Invoke QueryPerformanceCounter, Addr IniTime
                      
                               Invoke CaptureScreen ; Function capture the screen.

                        Invoke QueryPerformanceCounter, Addr FinTime


                        Xor Edx, Edx
                        Mov Eax, DWord Ptr FinTime
                        Mov Ebx, DWord Ptr IniTime
                        Sub Eax, Ebx
                        Mov Ebx, 1000
                        Mul Ebx
                        Mov Ebx, DWord Ptr pc_frequency
                        Div Ebx

.
.
.

dedndave

#22
;calculate performance counter counts per millisecond
;this only needs to be done once, at program initialization
;the result may then replace the low dword of pc_frequency

    mov     eax,dword ptr pc_frequency
    mov     edx,dword ptr pc_frequency[4]
    mov     ecx,1000
    div     ecx
;round to nearest
    shr     ecx,1
    cmp     edx,ecx
    sbb     eax,-1
    mov dword ptr pc_frequency,eax

;then, to calculate elapsed time...

    mov     eax,dword ptr FinTime
    mov     edx,dword ptr FinTime[4]
    mov     ecx,dword ptr pc_frequency
    sub     eax,dword ptr IniTime
    sbb     edx,dword ptr IniTime[4]
    div     ecx
;round to nearest
    shl     edx,1
    cmp     edx,ecx
    sbb     eax,-1

Farabi

I think you can use the Bitblt calling on separate thread, and then set the thread to run each 100ms by set the thread execution delay using Sleep function.
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

Fraile

Hi all,

Attached a example, for screen capture.

Screen capture at 25 FPS.

I capture the screen using BitBlt and GetDiBits for save bits and then send. I do not know if I can use only GetDibits for capture the bits. You know if you can?

I'm desperate!. Thanks in advance

Fraile

Hi all,

I'm debugging my program, I have seen, a problem in my send by socket.

I use socket Async, I use the function "WSAAsyncSelect" for know when to send packet.

What type of socket should I use me?, socket type of blocking or not?

Thanks is advance!.

Fraile

Hi all,

The performance problem is in the size of image.

Anyone have any example to zlib version 1.2.8?, for  function "compress".

I  tried "zlibstat.lib and zlibstat.inc" but gives error: "zlibstat.lib(crc32.obj) : fatal error LNK1103: debugging information corrupt; recompile module"

If anyone has ".Lib and .Inc" would greatly appreciate it.

Thank you very much.

dedndave

use the forum search tool for "zlib"
i seem to recall someone playing with that a while back

Fraile

Hi Debndave,

In the forum mams32, I have seen some examples and I have also read your manual and faq to zlib.

But I can not make it work, the function "compress/uncompress"

I have the following error:

"fatal error LNK1103: debugging information corrupt; recompile module"

You could help me?.
you would have some example for masm32? Or zlib.lib and zlib.inc for masm32?.

Thank is advance.

fearless

This might be something that will help you: http://www.masmforum.com/board/index.php?topic=9039.0

Ive attached zlibstat.inc and zlibstat.lib (which is zlib v1.1.4) unfortunately i havent been able to find a newer version of the static library or compile it from the various sources online - always get issues with unresolved externals and name decoration issues (even using vortex's undecor tool). Maybe someone else can take a stab at compiling a static zlib library that can be linked with assembler projects. Anyhow v1.1.4 works mostly, and this is the version i used for the zlibextract lib i created as well, which can be found in the following thread http://masm32.com/board/index.php?topic=421.0