Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

_WinAPI_CreateCompatibleBitmap to file

$
0
0

Hi guys

I'm seaching an alternative way to ScreenCapture UDF. Why? I think GDI+ is slow if you need to capture many images  :D

Searching on the web for the fastest method i have found:

1) Using Surface DirectX method

2) Using BitBlt method

 

The Directx method ( here you can find and example in C# ) is probably tha fastest but it's totally out of my knowledge, and i'm not sure can be done in autoit.

For the second i'm sure can be done in autoit and this is what i have make:

AutoIt         
#include <WinAPI.au3> ;~ #include <ScreenCapture.au3> ; Testin purpose Global Const $SRCCOPY = 0x00CC0020 $hDDC = _WinAPI_GetDC(0) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, @DesktopWidth, @DesktopHeight) _WinAPI_SelectObject($hCDC, $hBMP) _WinAPI_BitBlt($hCDC, 0, 0, @DesktopWidth, @DesktopHeight, $hDDC, 0, 0, $SRCCOPY) _WinAPI_ReleaseDC(0, $hDDC) _WinAPI_DeleteDC($hCDC) ;~ _ScreenCapture_SaveImage(@ScriptDir & "\GDIPlus_Image.jpg", $hBMP) ; testing purpose _WinAPI_SaveBMP(@ScriptDir & "\GDIPlus_Image.bmp", $hBMP) ; BMP is sure, PNG if possible. Func _WinAPI_SaveBMP($sFilename, $hData)     $file = _WinAPI_CreateFile($sFileName)     _WinAPI_CloseHandle($file) ;~  _WinAPI_WriteFile ; ---> Write file header and info header ;~  _WinAPI_CloseHandle($file) ; Close the handle ;~  _WinAPI_WriteFile ; ---> Write data of the bitmap ;~  _WinAPI_CloseHandle($file) EndFunc

As you can see, work if i use GDI-ScreenCapture UDF but the goal is avoid that, if i need to use GDI i'll use the UDF :D

The main problem is i don't know how to write in the file the information stored in _WinAPI_CreateCompatibleBitmap ( so Save HBITMAP to file trans.gif?cver=0%0D%0A)

I need to create the file header, info header and then write the data? ( i think :D ) but i'm here because i need an help for do the last part of the code.

Thanks


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>