So, wie die Überschrift schon sagt, die folgende Funktion erlaubt es ein Bild aus dem Internet zu laden(auch Bilder von durch Passwort geschützte Websiten, da es über TCP geht) und gibt dann ohne zu speichern den Handle des Images (GDI+) zurück.
Schaut es euch an und postet euer Meinung...Ich freu mich schon darauf
Spoiler anzeigen
#include
#include
#Include
#include
#NoTrayIcon
_GDIPlus_Startup()
$hwnd = GUICreate("Display image from memory", 600,100,-1,-1,-1, bitor($WS_EX_LAYERED,$WS_EX_TOOLWINDOW))
GUISetState()
WinSetOnTop($hwnd,"",1)
;Load Image
$hImage = _GDIPlus_ImageLoadFromInet( "http://www.autoit.de", "/wcf/images/future/autoit_logo_gtaspider.png")
;Show Image
SetBitmap($hwnd, $hImage, 255)
;Exit:
for $i = 255 to 0 step -1
SetBitmap($hwnd, $hImage, $i)
Sleep(20)
Next
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
Exit
;-----------------------------------------------------------------------------------------------------------------
; Author: Faweyr
; Thanks: Upload Function: @night@ ( http://www.autoitbot.de )
; Binary to Image: UEZ ( http://www.autoit.de )
; Function: _GDIPlus_LoadWebImage( $sHost, $sSeite)
; Parameter: $sHost = Host der Seite (zb. http://www.autoit.de)
; $sSeite = Der Link zum Bild ohne den Hostnamen (zb. /wcf/images/future/autoit_logo_gtaspider.png )
; Note: Läd ein Bild aus dem Inet und gibt das Handle (GDI+) zurück ohne es als Datei abzuspeichern
; Funktioniert auch bei Passwort geschützte Bereiche, da es über TCP funktioniert
; Return: Fehler: 0
; Erfolg: Handle of Image
; Error: 0 = Succes
; 1 = Can´t connected
; Example: _GDIPlus_ImageLoadFromInet( "http://www.autoit.de", "/wcf/images/future/autoit_logo_gtaspider.png")
;-----------------------------------------------------------------------------------------------------------------
Func _GDIPlus_ImageLoadFromInet( $sHost, $sSeite)
If StringInStr($sHost, "http://") Then $sHost = StringReplace($sHost, "http://", "")
If StringRegExp($sHost, "\.../") Then $sHost = Stringreplace($sHost, "/", "")
TCPStartup()
$sIp = TCPNameToIP($sHost)
$sData = "GET "&$sSeite&" HTTP/1.1" & @crlf & _
"Host: " & $sHost & @crlf & _
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)" & @crlf & _
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" & @crlf & _
"Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3" & @crlf & _
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" & @crlf & _
"Connection: close" & @crlf & @CRLF
$sSocket = TCPConnect($sIp, 80)
TCPSend($sSocket, $sData)
If @error Then return Seterror(1)
Local $sRecv_header = "", $sRecv_binary = "0x"
Do
$sRecv_header = TCPRecv($sSocket, 1)
until $sRecv_header <> ""
Do
$sRecv_header &= TCPRecv($sSocket, 1)
until StringInStr($sRecv_header, @crlf & @crlf)
$aArray_help = _stringbetween($sRecv_header, 'Content-Length: ', @crlf)
If NOT isarray($aArray_help) Then
TCPCloseSocket($sSocket)
TCPShutdown()
return Seterror(1)
EndIf
$iBytes = $aArray_help[0]
Do
$sRecv_binary &= StringTrimLeft(TCPRecv($sSocket, 1024, 1),2)
Until BinaryLen( Binary($sRecv_binary) ) >= $iBytes
TCPCloseSocket($sSocket)
TCPShutdown()
$memBitmap = Binary($sRecv_binary)
$len = BinaryLen($memBitmap)
$hData = _MemGlobalAlloc($len, 0x0002)
$pData = _MemGlobalLock($hData)
$tMem = DllStructCreate("byte[" & $len & "]", $pData)
DllStructSetData($tMem, 1, $memBitmap)
_MemGlobalUnlock($hData)
$aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "hwnd", $pData, "int", True, "ptr*", 0)
If @error Then Return SetError(@error, @extended, 0)
$aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $aResult[3], "int*", 0)
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[2]
EndFunc
Func SetBitmap($hGUI, $hImage, $iOpacity)
Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
$hScrDC = _WinAPI_GetDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
$hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize )
DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth ($hImage))
DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha" , $iOpacity )
DllStructSetData($tBlend, "Format", 1)
_WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
_WinAPI_ReleaseDC (0, $hScrDC)
_WinAPI_SelectObject($hMemDC, $hOld)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteDC ($hMemDC)
EndFunc