Bilgus Posted May 4, 2020 Share Posted May 4, 2020 (edited) I was looking through the gdiplus.dll and saw the cached bitmap functions https://docs.microsoft.com/en-us/windows/win32/api/gdiplusheaders/nl-gdiplusheaders-cachedbitmap Quote A CachedBitmap object stores a bitmap in a format that is optimized for display on a particular device. To display a cached bitmap, call the Graphics::DrawCachedBitmap method. Functions: Spoiler Func __GDIPlus_GraphicsDrawCachedBitmap($hGraphics, $hCachedBitmap, $iX, $iY) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawCachedBitmap", "handle", $hGraphics, "handle", $hCachedBitmap, "int", $iX, "int", $iY) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func __GDIPlus_CachedBitmapCreate($hGraphics, $hBitmap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateCachedBitmap", "handle", $hBitmap, "handle", $hGraphics, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[3] EndFunc Func __GDIPlus_CachedBitmapDispose($hCachedBitmap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDeleteCachedBitmap", "handle", $hCachedBitmap) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc ;Short example (pseudocode!) Local $iW, $iH, $hWnd ;<- You supply these Local $hG = _GDIPlus_GraphicsCreateFromHWND($hWnd) Local $hBmp = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hG) Local $hCachedBmp = __GDIPlus_CachedBitmapCreate($hG, $hBmp) __GDIPlus_GraphicsDrawCachedBitmap($hG, $hCachedBmp, 0, 0) ;(hGraphics, hCachedBmp, X, Y) __GDIPlus_CachedBitmapDispose($hCachedBmp) Edited May 5, 2020 by Bilgus !G pixelsearch and Nine 2 Link to comment Share on other sites More sharing options...
Nine Posted May 5, 2020 Share Posted May 5, 2020 (edited) Nice finding @Bilgus. I just incorporated it in my Multiple GIF automation UDF, and it is working very good. Very fast, although I need to make some more tests. Thanks. Edit : __GDIPlus_CachedBitmapDispose($hCachedBmp) always return False with error 3 (OutOfMemory). The value of the handle is valid as it is draw correctly. But in a GIF situation, there is a terrible memory leaks because it is unable to delete the object and after awhile, it makes the script crash. Investigating... Edited May 5, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Nine Posted May 5, 2020 Share Posted May 5, 2020 Found the problem...There is a typo in the API function name (capital G)...I misinterpreted the returning result, I first thought it was the function returning 3, but it was the dllcall that was returning @error 3...Now all works wonderfully. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Bilgus Posted May 5, 2020 Author Share Posted May 5, 2020 Sorry I typed those out by hand guess I missed the Capital G! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now