sandin Posted March 6, 2009 Share Posted March 6, 2009 (edited) I have this script: expandcollapse popup#include <WinAPI.au3> #include <GUIConstantsEx.au3> #Include <ScreenCapture.au3> Dim $image = @TempDir & "\i_pic.jpg" dim $image2 = @TempDir & "\i_pic2.jpg" _ScreenShot_of_a_window(WinGetHandle("[ACTIVE]")) Func _ScreenShot_of_a_window($i_win_handle) Local $iW = 380, $iH = 330 ;resized resolution ;-- Capture image: ---- Local $hDC = _WinAPI_GetWindowDC($i_win_handle) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hWinPos = WinGetPos($i_win_handle) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $hWinPos[2], $hWinPos[3]) _WinAPI_SelectObject($hMemDC, $hBitmap) _PrintWindow($i_win_handle, $hMemDC) _WinAPI_DeleteDC($hMemDC) _WinAPI_ReleaseDC($i_win_handle, $hDC) Local $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) _ScreenCapture_SaveImage($image, $hBitmap) _WinAPI_DeleteObject($hBitmap) ;-- resize image: ---- $hWnd = _WinAPI_GetDesktopWindow() $hDC = _WinAPI_GetDC($i_win_handle) $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) _WinAPI_ReleaseDC($hWnd, $hDC) _GDIPlus_Startup() $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) $hImage2 = _GDIPlus_ImageLoadFromFile($image) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1) _GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH) _GDIPlus_ImageSaveToFile($hImage1, $image2) _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _GDIPlus_GraphicsDispose ($hGraphic) _WinAPI_DeleteObject($hBMP) _GDIPlus_Shutdown() ;-- display image: ---- ShellExecuteWait($image2) FileDelete($image) FileDelete($image2) EndFunc Func _PrintWindow($hWnd, $hMemDC, $iFlag = 0) $aRet = DllCall("User32.dll", "int", "PrintWindow", _ "hwnd", $hWnd, _ "hwnd", $hMemDC, _ "int", $iFlag) Return $aRet[0] EndFunc ;==>_PrintWindow I lack GDI+ skills, so I need help with it, in this function, the script will save image to HDD, then resize it, and then display it, is it possible to do the same thing, but without saving the image to the HDD? Like: take ths Screen Shot, then resize it, and then save to HDD. Edited March 8, 2009 by sandin Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
GreenCan Posted March 6, 2009 Share Posted March 6, 2009 Check _GDIPlus_MatrixScale The example does what you want to do. GreenCan Contributions CheckUpdate - SelfUpdating script ------- Self updating script Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple MsgBox with CountDown ------------------- MsgBox with visual countdown Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV) USB Drive Tools ------------------------------ Tool to help you with your USB drive management Input Period udf ------------------------------ GUI for a period input Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette Excel Chart UDF ----------------------------- Collaboration project with water GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm TaskListAllDetailed --------------------------- List All Scheduled Tasks Computer Info --------------------------------- A collection of information for helpdesk Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only) Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane Oracle SQL Report Generator ------------- Oracle Report generator using SQL SQLite Report Generator ------------------- SQLite Report generator using SQL SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access Animated animals ----------------------------- Fun: Moving animated objects Perforated image in GUI --------------------- Fun: Perforate your image with image objects UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool Visual Image effect (GUI) -------------------- Visually apply effects on an image    Link to comment Share on other sites More sharing options...
sandin Posted March 7, 2009 Author Share Posted March 7, 2009 tnx, but with matrix scale I get disoriented picture like this:and with my way (the one posted above), I get like this:the matrix scale 0.x get's the picture disoriented, it works well for 1.x+ but not for 0.x scale...though tnx for a reply Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
monoceres Posted March 7, 2009 Share Posted March 7, 2009 Better? #include <GDIPlus.au3> #include <ScreenCapture.au3> _GDIPlus_Startup() $hbitmap=_ScreenCapture_Capture() _SavehBitmapEx($hbitmap,"test.bmp",@DesktopWidth/2,@DesktopHeight/2) _WinAPI_DeleteObject($hbitmap) _GDIPLUS_SHutdown() Func _SavehBitmapEx($hBitmap,$sFileName,$iWidth,$iHeight) $bitmap=_GDIPlus_BitmapCreateFromHBITMAP($hbitmap) $graphics=_GDIPlus_ImageGetGraphicsContext($bitmap) $resizedbitmap=_GDIPlus_BitmapCreateFromGraphics($iWidth,$iHeight,$graphics) $graphics2=_GDIPlus_ImageGetGraphicsContext($resizedbitmap) _GDIPlus_GraphicsDrawImageRect($graphics2,$bitmap,0,0,$iWidth,$iHeight) _GDIPlus_ImageSaveToFile($resizedbitmap,$sFileName) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_GraphicsDispose($graphics2) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_BitmapDispose($resizedbitmap) EndFunc Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
sandin Posted March 8, 2009 Author Share Posted March 8, 2009 (edited) thank you for reply, but it's the same thing as with the matrix command, try this script: expandcollapse popup#include <WinAPI.au3> #include <GDIPlus.au3> #Include <ScreenCapture.au3> Global $SS_width = @DesktopWidth/4 Global $SS_height = @DesktopHeight/4 Global $image = @TempDir & "\i_pic.jpg" Global $image2 = @TempDir & "\i_pic2.jpg" Global $image3 = @TempDir & "\i_pic3.jpg" _ScreenShot_of_a_window(WinGetHandle("[ACTIVE]"), $SS_width, $SS_height) _ScreenShot_direct_resize(WinGetHandle("[ACTIVE]"), $SS_width, $SS_height) FileDelete($image) ShellExecuteWait($image2) FileDelete($image2) FileDelete($image3) Func _ScreenShot_of_a_window($i_win_handle, $iW, $iH) ;-- Capture image: ---- Local $hDC = _WinAPI_GetWindowDC($i_win_handle) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hWinPos = WinGetPos($i_win_handle) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $hWinPos[2], $hWinPos[3]) _WinAPI_SelectObject($hMemDC, $hBitmap) _PrintWindow($i_win_handle, $hMemDC) _WinAPI_DeleteDC($hMemDC) _WinAPI_ReleaseDC($i_win_handle, $hDC) _GDIPlus_Startup() Local $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) _ScreenCapture_SaveImage($image, $hBitmap) _WinAPI_DeleteObject($hBitmap) ;-- resize image: ---- $hWnd = _WinAPI_GetDesktopWindow() $hDC = _WinAPI_GetDC($i_win_handle) $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) _WinAPI_ReleaseDC($hWnd, $hDC) $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) $hImage2 = _GDIPlus_ImageLoadFromFile($image) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1) _GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH) _GDIPlus_ImageSaveToFile($hImage1, $image2) _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _GDIPlus_GraphicsDispose ($hGraphic) _WinAPI_DeleteObject($hBMP) _GDIPlus_Shutdown() EndFunc func _ScreenShot_direct_resize($i_win_handle, $iW, $iH) _GDIPlus_Startup() Local $hDC = _WinAPI_GetWindowDC($i_win_handle) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hWinPos = WinGetPos($i_win_handle) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $hWinPos[2], $hWinPos[3]) _WinAPI_SelectObject($hMemDC, $hBitmap) _PrintWindow($i_win_handle, $hMemDC) _WinAPI_DeleteDC($hMemDC) _WinAPI_ReleaseDC($i_win_handle, $hDC) _SavehBitmapEx($hBitmap, $image3, $iW, $iH) _WinAPI_DeleteObject($hBitmap) _GDIPLUS_SHutdown() EndFunc Func _SavehBitmapEx($hBitmap,$sFileName,$iWidth,$iHeight) $bitmap=_GDIPlus_BitmapCreateFromHBITMAP($hbitmap) $graphics=_GDIPlus_ImageGetGraphicsContext($bitmap) $resizedbitmap=_GDIPlus_BitmapCreateFromGraphics($iWidth,$iHeight,$graphics) $graphics2=_GDIPlus_ImageGetGraphicsContext($resizedbitmap) _GDIPlus_GraphicsDrawImageRect($graphics2,$bitmap,0,0,$iWidth,$iHeight) _GDIPlus_ImageSaveToFile($resizedbitmap,$sFileName) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_GraphicsDispose($graphics2) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_BitmapDispose($resizedbitmap) EndFunc Func _PrintWindow($hWnd, $hMemDC, $iFlag = 0) $aRet = DllCall("User32.dll", "int", "PrintWindow", _ "hwnd", $hWnd, _ "hwnd", $hMemDC, _ "int", $iFlag) Return $aRet[0] EndFunc ;==>_PrintWindow and compare 2 images, I'm sure you'll notice the quality difference p.s. I also noticed that the first function makes picture even smaller, and more recognizable (but it's slower, and speed is crucial in my way, that's why I'm looking an alternative to my func). Edited March 8, 2009 by sandin Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
monoceres Posted March 8, 2009 Share Posted March 8, 2009 Setting the interpolation mode seems to give better results expandcollapse popup#include <GDIPlus.au3> #include <ScreenCapture.au3> Global Const $InterpolationModeInvalid = -1 Global Const $InterpolationModeDefault = 0 Global Const $InterpolationModeLowQuality = 1 Global Const $InterpolationModeHighQuality = 2 Global Const $InterpolationModeBilinear = 3 Global Const $InterpolationModeBicubic = 4 Global Const $InterpolationModeNearestNeighbor = 5 Global Const $InterpolationModeHighQualityBilinear = 6 Global Const $InterpolationModeHighQualityBicubic = 7 _GDIPlus_Startup() $hbitmap = _ScreenCapture_Capture() _SavehBitmapEx($hbitmap, "test.bmp", @DesktopWidth / 2, @DesktopHeight / 2) _WinAPI_DeleteObject($hbitmap) _GDIPlus_Shutdown() Func _SavehBitmapEx($hbitmap, $sFileName, $iWidth, $iHeight) $bitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbitmap) $graphics = _GDIPlus_ImageGetGraphicsContext($bitmap) $resizedbitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $graphics) $graphics2 = _GDIPlus_ImageGetGraphicsContext($resizedbitmap) _GDIPLUS_GraphicsSetInterpolationMode($graphics2, $InterpolationModeHighQualityBicubic) _GDIPlus_GraphicsDrawImageRect($graphics2, $bitmap, 0, 0, $iWidth, $iHeight) _GDIPlus_ImageSaveToFile($resizedbitmap, $sFileName) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_GraphicsDispose($graphics2) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_BitmapDispose($resizedbitmap) EndFunc ;==>_SavehBitmapEx Func _GDIPLUS_GraphicsSetInterpolationMode($hGraphics, $iMode) DllCall($ghGDIPDll, "int", "GdipSetInterpolationMode", "hwnd", $hGraphics,"int",$iMode) EndFunc ;==>_GDIPLUS_GraphicsSetInterpolationMode Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
sandin Posted March 8, 2009 Author Share Posted March 8, 2009 hey, that's great! Thank you very much Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll 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