Opened 17 years ago
Closed 17 years ago
#290 closed Bug (Completed)
_WinAPI_FloatToInt() --> obsolete in GDIPlus.au3
Reported by: | Zedna | Owned by: | Gary |
---|---|---|---|
Milestone: | 3.2.13.0 | Component: | Standard UDFs |
Version: | 3.2.10.0 | Severity: | None |
Keywords: | Cc: |
Description
_WinAPI_FloatToInt() is declared in WinApi.au3 UDF
and it's used in GDIPlus.au3 UDF only.
PaulIA created it in his Auto3Library as workaround for missing float type support in DllCall().
But later Jon added support for float type into DllCall()
but PaulIA has left forum already so this (now not neccessary) workaround is still there.
Princip of workaround was in creating structure for DllCall with int type instead of float and place data into it converted by _WinAPI_FloatToInt(). Then in DllCall() was used type int instead of float.
It's nice visible in this example for _GDIPlus_DrawImagePoints()
I removed workaround and tested it on WINXP - it works OK:
_GDIPlus_DrawImagePoints2() is corrected original _GDIPlus_DrawImagePoints():
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GDIPlus.au3> #include <ScreenCapture.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphic ; 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) _GDIPlus_DrawImagePoints2($hGraphic, $hImage2, 100, 100, 600, 170, 130, 570) ; Draw a frame around the inserted image _GDIPlus_GraphicsDrawRect($hGraphic, 100, 100, 400, 300) ; Save resultant image _GDIPlus_ImageSaveToFile($hImage1, @ScriptDir & "\GDIPlus_Image.jpg") ; Clean up resources _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _WinAPI_DeleteObject($hBitmap1) _WinAPI_DeleteObject($hBitmap2) ; Shut down GDI+ library _GDIPlus_Shutdown() EndFunc ;==>_Main Func _GDIPlus_DrawImagePoints2($hGraphic, $hImage, $nULX, $nULY, $nURX, $nURY, $nLLX, $nLLY, $count = 3) Local $tPoint, $pPoint, $aResult $tPoint = DllStructCreate("float X;float Y;float X2;float Y2;float X3;float Y3") DllStructSetData($tPoint, "X", $nULX) DllStructSetData($tPoint, "Y", $nULY) DllStructSetData($tPoint, "X2", $nURX) DllStructSetData($tPoint, "Y2", $nURY) DllStructSetData($tPoint, "X3", $nLLX) DllStructSetData($tPoint, "Y3", $nLLY) $pPoint = DllStructGetPtr($tPoint) $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImagePoints", _ "hwnd", $hGraphic, _ "hwnd", $hImage, _ "ptr", $pPoint, _ "int", $count) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_DrawImagePoints ;~ Func _GDIPlus_DrawImagePoints($hGraphic, $hImage, $nULX, $nULY, $nURX, $nURY, $nLLX, $nLLY, $count = 3) ;~ Local $iULX, $iULY, $iURX, $iURY, $iLLX, $iLLY, $tPoint, $pPoint, $aResult ;~ ;~ $iULX = _WinAPI_FloatToInt($nULX) ;~ $iULY = _WinAPI_FloatToInt($nULY) ;~ $iURX = _WinAPI_FloatToInt($nURX) ;~ $iURY = _WinAPI_FloatToInt($nURY) ;~ $iLLX = _WinAPI_FloatToInt($nLLX) ;~ $iLLY = _WinAPI_FloatToInt($nLLY) ;~ $tPoint = DllStructCreate("int X;int Y;int X2;int Y2;int X3;int Y3") ;~ DllStructSetData($tPoint, "X", $iULX) ;~ DllStructSetData($tPoint, "Y", $iULY) ;~ DllStructSetData($tPoint, "X2", $iURX) ;~ DllStructSetData($tPoint, "Y2", $iURY) ;~ DllStructSetData($tPoint, "X3", $iLLX) ;~ DllStructSetData($tPoint, "Y3", $iLLY) ;~ $pPoint = DllStructGetPtr($tPoint) ;~ $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImagePoints", _ ;~ "hwnd", $hGraphic, _ ;~ "hwnd", $hImage, _ ;~ "ptr", $pPoint, _ ;~ "int", $count) ;~ Return SetError($aResult[0], 0, $aResult[0] = 0) ;~ EndFunc ;==>_GDIPlus_DrawImagePoints
Attachments (0)
Change History (1)
comment:1 Changed 17 years ago by Gary
- Milestone set to 3.2.13.0
- Resolution set to Completed
- Status changed from new to closed
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Changed in version: 3.2.13.0