Hey, ich hab in den letzten Tagen im Internet ein Vorher/Nacher Bild von Japan gesehen, da ist mir die Idee gekommen soetwas auch in AutoIt zu Coden.
Ich weiß nicht, ob es man es als UDF bezeichnen kann, da es nur eine (Mit Startup 2) Funktionen sind.
Also, man kann X Koordinaten, Y Koordinaten, Breite und Höhe einer Fläche auswählen auf der 2 Bilder, durch eine Art Balken getrennt sind. Nun kann man den Balken so verschieben, das ein bestimmtes Bild größer ist als das andere, das andere wird dann sehr klein.
Schaut es euch an und gebt nützliche Rückmeldung, wie ihr es findet und ob es Verbesserungsvorschläge gibt.
Die (UDF?):
[autoit]Func _GDIPlus_PicSliderStartup($iX, $iY, $iWidth)
$SliderX = ($iX + $iWidth / 2)
$SliderY = $iY
$hImage1X = 0
$hImage1Width = _GDIPlus_ImageGetWidth($hImage1) * ($SliderX / ($iX + $iWidth - 50 - $iX))
$himage2X = 0
$hImage2Width = _GDIPlus_ImageGetWidth($hImage2)
EndFunc ;==>_GDIPlus_PicSliderStartup
Func _Gdiplus_GraphicsDrawPicSlider($hGraphics, $iX, $iY, $iWidth, $iHeight, $hImage1, $hImage2, $hBrush)
$CursorInfo = GUIGetCursorInfo()
If IsArray($CursorInfo) Then
If $CursorInfo[0] >= $iX + 40 And $CursorInfo[0] <= ($iX + $iWidth) - 40 And $CursorInfo[1] >= $iY And $CursorInfo[1] <= $iY + $iHeight Then
$SliderX = $CursorInfo[0] - 10
$hImage1Width = _GDIPlus_ImageGetWidth($hImage1) * ($SliderX / ($iX + $iWidth - 50-$iX))
EndIf
EndIf
$DrawWidth = $SliderX
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage2, $iX + 52, $iY, $iWidth - 52, $iHeight)
_GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hImage1, 0, 0, $hImage1Width, _GDIPlus_ImageGetHeight($hImage1), $iX, $iY, $DrawWidth, $iHeight)
_GDIPlus_GraphicsFillRect($hGraphics, $SliderX, $SliderY, 20, $iHeight, $hBrush)
EndFunc ;==>_Gdiplus_GraphicsDrawPicSlider
Beispielscript:
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
Opt("GUIOnEventMode", 1)
_GDIPlus_Startup()
Global $iWidth = 700, $iHeight = 500, $SliderX, $SliderY, $DrawWidth
Global $hImage1X
Global $hImage1Width
Global $himage2X
Global $hImage2Width
$File1 = FileOpenDialog("Wählen Sie ein Bild.", @DesktopDir & "\", "(*.jpg;*.png)")
$File2 = FileOpenDialog("Wählen Sie ein Bild.", @DesktopDir & "\", "(*.jpg;*.png)")
$hWnd = GUICreate("GDI+ PicSlider", $iWidth, $iHeight)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
GUISetState()
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
$hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
$hImage1 = _GDIPlus_ImageLoadFromFile($File1)
$hImage2 = _GDIPlus_ImageLoadFromFile($File2)
$hBrush = _GDIPlus_BrushCreateSolid(0xff500000)
_GDIPlus_PicSliderStartup(0, 0, 700)
While Sleep(0)
_GDIPlus_GraphicsClear($hBackbuffer, 0xffffffff)
$hPicSlider = _GDIPlus_GraphicsDrawPicSlider($hBackbuffer, 0, 0, 700, 400, $hImage1, $hImage2, $hBrush)
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight)
WEnd
Func _GDIPlus_PicSliderStartup($iX, $iY, $iWidth)
$SliderX = ($iX + $iWidth / 2)
$SliderY = $iY
$hImage1X = 0
$hImage1Width = _GDIPlus_ImageGetWidth($hImage1) * ($SliderX / ($iX + $iWidth - 50 - $iX))
$himage2X = 0
$hImage2Width = _GDIPlus_ImageGetWidth($hImage2)
EndFunc ;==>_GDIPlus_PicSliderStartup
Func _Gdiplus_GraphicsDrawPicSlider($hGraphics, $iX, $iY, $iWidth, $iHeight, $hImage1, $hImage2, $hBrush)
$CursorInfo = GUIGetCursorInfo()
If IsArray($CursorInfo) Then
If $CursorInfo[0] >= $iX + 40 And $CursorInfo[0] <= ($iX + $iWidth) - 40 And $CursorInfo[1] >= $iY And $CursorInfo[1] <= $iY + $iHeight Then
$SliderX = $CursorInfo[0] - 10
$hImage1Width = _GDIPlus_ImageGetWidth($hImage1) * ($SliderX / ($iX + $iWidth - 50-$iX))
EndIf
EndIf
$DrawWidth = $SliderX
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage2, $iX + 52, $iY, $iWidth - 52, $iHeight)
_GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hImage1, 0, 0, $hImage1Width, _GDIPlus_ImageGetHeight($hImage1), $iX, $iY, $DrawWidth, $iHeight)
_GDIPlus_GraphicsFillRect($hGraphics, $SliderX, $SliderY, 20, $iHeight, $hBrush)
EndFunc ;==>_Gdiplus_GraphicsDrawPicSlider
Func _exit()
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_ImageDispose($hImage2)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_exit
Danke im Vorraus für Rückmeldungen