Hallo,
Gegeben sei dieser Code:
Spoiler anzeigen
#include <GDIPlus.au3>
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hGUIMinimap = GUICreate("", 400, 200)
$hGUIMinimap1 = GUICtrlCreatePic("", 5, 5, 190, 190)
$hGUIMinimap2 = GUICtrlCreatePic("", 205, 5, 190, 190)
GUISetState()
_FillGraphics()
While 1
Switch GUIGetMsg()
Case - 3
Exit
EndSwitch
Sleep(1)
WEnd
Func _FillGraphics()
$hBitmap = _GDIPlus_ImageLoadFromFile("auge.jpg")
$hBitmap2 = _GDIPlus_BitmapCloneArea($hBitmap, 0, 0, 190, 190)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap2)
$hNewBitmapHandle = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap2)
_SetBitmapToCtrl($hGUIMinimap1, $hNewBitmapHandle)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_BitmapDispose($hBitmap)
_WinAPI_DeleteObject($hNewBitmapHandle)
$hBitmap = _GDIPlus_ImageLoadFromFile("auge.jpg")
$hBitmap2 = _GDIPlus_BitmapCloneArea($hBitmap, -1, 0, 190, 190)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap2)
$hNewBitmapHandle = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap2)
_SetBitmapToCtrl($hGUIMinimap2, $hNewBitmapHandle)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_BitmapDispose($hBitmap)
_WinAPI_DeleteObject($hNewBitmapHandle)
EndFunc ;==>_PrepareBitmap
Func _SetBitmapToCtrl($vCtrlID, $hBitmap)
Local $hWnd = GUICtrlGetHandle($vCtrlID)
If $hWnd = 0 Then Return SetError(1, 0, 0)
Local $vOldStyle = _WinAPI_GetWindowLong($hWnd, -16)
_WinAPI_SetWindowLong($hWnd, -16, BitOR($vOldStyle, 0xE))
Local $vOldBmp = _SendMessage($hWnd, 0x0172, 0, $hBitmap)
If $vOldBmp <> 0 Then _WinAPI_DeleteObject($vOldBmp)
EndFunc ;==>_SetBitmapToCtrl
Dazu wird dieses Bild benötigt (im selben Ordner wie das Script).
[Blockierte Grafik: http://img5.imagebanana.com/img/2fu4zdkz/auge.jpg]
Nun zum Problem:
Es sollten 2 Bilder im Programm erscheinen, jeweils ein geklonter Bereich aus dem Ursprungsbild, aber die Funktion zum Klonen des Bereiches funktioniert nur, wenn man nicht über das Bild in irgendeine Richtung hinaus klont. Das Bild muss aber immer die Breite von 190 und die Höhe von 190 Pixeln haben. Früher habe ich die Funktion DrawImageRectRect benutzt, die aber beim Wechsel des Bildes des öfteren geflackert hat. Der Funktion ist es egal, wenn man über das Bild hinausschießt, sie hat sich einfach eine weiße Fläsche dahin gedacht, CloneArea aber liefert einen Fehler in Zeile 31, aufgrund der -1. Kann ich CloneArea irgendwie umgehen?