Malkey Posted February 18, 2008 Share Posted February 18, 2008 (edited) Unsuccessfully, I have been trying to figure out to use the matrix commands in GDIPlus. A little example would be greatly appreciated. This is my most recent unsuccessful attempt. expandcollapse popup#include <GDIPlus.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphic, $hPen1,$hPen2, $hMatrix, $hBitmap3 ; Initialize GDI+ library _GDIPlus_Startup () ; Capture full screen $hBitmap1 = _ScreenCapture_Capture ("") $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap1) ; Capture screen region $hBitmap2 = _ScreenCapture_Capture ("", 0, 0, 400, 300) ;Rotation Matrix $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixRotate($hMatrix, 30, "False") _GDIPlus_GraphicsSetTransform($hBitmap2 , $hMatrix) $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap2) ; Draw one image in another $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1) _GDIPlus_GraphicsDrawImage ($hGraphic, $hImage2, 100, 100) ;get pen + color $hPen2 = _GDIPlus_PenCreate(0xFFFF8000, 8) ; Draw a frame around the inserted image _GDIPlus_GraphicsDrawRect ($hGraphic, 100, 100, 400, 300, $hPen2) ; Save resultant image _GDIPlus_ImageSaveToFile ($hImage1, @MyDocumentsDir & "\GDIPlus_Image1.jpg") ; Clean up resources _GDIPlus_ImageDispose ($hImage1) _GDIPlus_ImageDispose ($hImage2) _WinAPI_DeleteObject ($hBitmap1) _WinAPI_DeleteObject ($hBitmap2) _GDIPlus_PenDispose ($hPen2) _WinAPI_DeleteObject ($hBitmap3) _GDIPlus_MatrixDispose($hMatrix) ; Shut down GDI+ library _GDIPlus_ShutDown () EndFunc ;==>_Main Edited February 18, 2008 by Malkey Link to comment Share on other sites More sharing options...
Malkey Posted February 18, 2008 Author Share Posted February 18, 2008 (edited) Forget this post, I got it. I was so close. expandcollapse popup#include <GDIPlus.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphic, $hPen1,$hPen2, $hMatrix, $hBitmap3 ; Initialize GDI+ library _GDIPlus_Startup () ; Capture full screen $hBitmap1 = _ScreenCapture_Capture ("") $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap1) ; Capture screen region $hBitmap2 = _ScreenCapture_Capture ("", 0, 0, 400, 300) $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap2) ; Draw one image in another $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1) ;Rotation Matrix $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixRotate($hMatrix, 30, "False") _GDIPlus_GraphicsSetTransform($hGraphic , $hMatrix) _GDIPlus_GraphicsDrawImage ($hGraphic, $hImage2, 100, 100) ;get pen + color $hPen2 = _GDIPlus_PenCreate(0xFFFF8000, 8) ; Draw a frame around the inserted image _GDIPlus_GraphicsDrawRect ($hGraphic, 100, 100, 400, 300, $hPen2) ; Save resultant image _GDIPlus_ImageSaveToFile ($hImage1, @MyDocumentsDir & "\GDIPlus_Image1.jpg") ; Clean up resources _GDIPlus_ImageDispose ($hImage1) _GDIPlus_ImageDispose ($hImage2) _WinAPI_DeleteObject ($hBitmap1) _WinAPI_DeleteObject ($hBitmap2) _GDIPlus_PenDispose ($hPen2) _WinAPI_DeleteObject ($hBitmap3) _GDIPlus_MatrixDispose($hMatrix) ; Shut down GDI+ library _GDIPlus_ShutDown () EndFunc ;==>_Main Thanks to anyone that tried. Edited February 18, 2008 by Malkey Link to comment Share on other sites More sharing options...
tic Posted February 21, 2008 Share Posted February 21, 2008 (edited) Forget this post, I got it. I was so close. expandcollapse popup#include <GDIPlus.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphic, $hPen1,$hPen2, $hMatrix, $hBitmap3 ; Initialize GDI+ library _GDIPlus_Startup () ; Capture full screen $hBitmap1 = _ScreenCapture_Capture ("") $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap1) ; Capture screen region $hBitmap2 = _ScreenCapture_Capture ("", 0, 0, 400, 300) $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap2) ; Draw one image in another $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1) ;Rotation Matrix $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixRotate($hMatrix, 30, "False") _GDIPlus_GraphicsSetTransform($hGraphic , $hMatrix) _GDIPlus_GraphicsDrawImage ($hGraphic, $hImage2, 100, 100) ;get pen + color $hPen2 = _GDIPlus_PenCreate(0xFFFF8000, 8) ; Draw a frame around the inserted image _GDIPlus_GraphicsDrawRect ($hGraphic, 100, 100, 400, 300, $hPen2) ; Save resultant image _GDIPlus_ImageSaveToFile ($hImage1, @MyDocumentsDir & "\GDIPlus_Image1.jpg") ; Clean up resources _GDIPlus_ImageDispose ($hImage1) _GDIPlus_ImageDispose ($hImage2) _WinAPI_DeleteObject ($hBitmap1) _WinAPI_DeleteObject ($hBitmap2) _GDIPlus_PenDispose ($hPen2) _WinAPI_DeleteObject ($hBitmap3) _GDIPlus_MatrixDispose($hMatrix) ; Shut down GDI+ library _GDIPlus_ShutDown () EndFunc ;==>_Main Thanks to anyone that tried. What is this dllcall?: _GDIPlus_GraphicsSetTransform($hGraphic , $hMatrix) do you have a link to the msdn page, or do you know what the wrapper or flat api that this is using is? Edit: Dont worry I see that it is GdipSetWorldTransform in the documentation Edited February 21, 2008 by tic 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