Could you help me . thx.
I don't want to download it to the disk.
show the image of web to the gui Topic is solved
-
- Posts: 4365
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: show the image of web to the gui
This works on Windows 7:
I'm not sure, whether it will work if you use Windows XP.
Code: Select all
url := "https://upload.wikimedia.org/wikipedia/commons/5/55/Tesseract.gif"
width := 200
height := 200
Gui, New, -DPIScale
Gui, Add, ActiveX, w%width% h%height% voDoc, htmlfile
oDoc.Write("<body style='margin: 0; overflow: hidden;'><img src='" url "' width='" width "' height='" height "'></body>")
Gui, Show
return
GuiClose:
ExitApp
Re: show the image of web to the gui
I know it.thx all the same.teadrinker wrote:This works on Windows 7:I'm not sure, whether it will work if you use Windows XP.Code: Select all
url := "https://upload.wikimedia.org/wikipedia/commons/5/55/Tesseract.gif" width := 200 height := 200 Gui, New, -DPIScale Gui, Add, ActiveX, w%width% h%height% voDoc, htmlfile oDoc.Write("<body style='margin: 0; overflow: hidden;'><img src='" url "' width='" width "' height='" height "'></body>") Gui, Show return GuiClose: ExitApp
But I want to get the data of imge to show in the gui(no downloading the image to disk).
-
- Posts: 4365
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: show the image of web to the gui Topic is solved
Code: Select all
imageUrl := "http://icons.iconarchive.com/icons/aha-soft/jewelry/256/Gem-icon.png"
Gui, Add, Pic,, % "HBITMAP:" . GetHBitmapFromImageURL(imageUrl)
Gui, Show
return
GuiClose:
ExitApp
GetHBitmapFromImageURL(url) {
oWhr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
oWhr.Open("GET", url, false)
oWhr.Send()
if (oWhr.Status != 200) {
MsgBox, Failed to load the image!
Return
}
contentType := oWhr.GetResponseHeader("Content-Type")
if !InStr(contentType, "image") {
MsgBox, URL doesn't link to an image!
Return
}
Return (new GDIp).HBitmapFromIStream(oWhr.ResponseStream)
}
class GDIp {
__New() {
if !DllCall("GetModuleHandle", Str, "gdiplus", Ptr)
DllCall("LoadLibrary", Str, "gdiplus")
VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
DllCall("gdiplus\GdiplusStartup", UPtrP, pToken, Ptr, &si, Ptr, 0)
this.token := pToken
}
__Delete() {
DllCall("gdiplus\GdiplusShutdown", Ptr, this.token)
if hModule := DllCall("GetModuleHandle", Str, "gdiplus", Ptr)
DllCall("FreeLibrary", Ptr, hModule)
}
HBitmapFromIStream(IStream) {
pStream := ComObjQuery(IStream, "{0000000C-0000-0000-C000-000000000046}")
DllCall("gdiplus\GdipCreateBitmapFromStream", Ptr, pStream, PtrP, pBitmap)
ObjRelease(pStream)
DllCall("OleAut32\VariantClear", PtrP, IStream)
DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", Ptr, pBitmap, PtrP, hBitmap, UInt, 0xFFFFFFFF)
DllCall("gdiplus\GdipDisposeImage", Ptr, pBitmap)
Return hBitmap
}
}
Re: show the image of web to the gui
teadrinker wrote:Something like this?Code: Select all
imageUrl := "http://icons.iconarchive.com/icons/aha-soft/jewelry/256/Gem-icon.png" Gui, Add, Pic,, % "HBITMAP:" . GetHBitmapFromImageURL(imageUrl) Gui, Show return GuiClose: ExitApp GetHBitmapFromImageURL(url) { oWhr := ComObjCreate("WinHttp.WinHttpRequest.5.1") oWhr.Open("GET", url, false) oWhr.Send() if (oWhr.Status != 200) { MsgBox, Failed to load the image! Return } contentType := oWhr.GetResponseHeader("Content-Type") if !InStr(contentType, "image") { MsgBox, URL doesn't link to an image! Return } Return (new GDIp).HBitmapFromIStream(oWhr.ResponseStream) } class GDIp { __New() { if !DllCall("GetModuleHandle", Str, "gdiplus", Ptr) DllCall("LoadLibrary", Str, "gdiplus") VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1) DllCall("gdiplus\GdiplusStartup", UPtrP, pToken, Ptr, &si, Ptr, 0) this.token := pToken } __Delete() { DllCall("gdiplus\GdiplusShutdown", Ptr, this.token) if hModule := DllCall("GetModuleHandle", Str, "gdiplus", Ptr) DllCall("FreeLibrary", Ptr, hModule) } HBitmapFromIStream(IStream) { pStream := ComObjQuery(IStream, "{0000000C-0000-0000-C000-000000000046}") DllCall("gdiplus\GdipCreateBitmapFromStream", Ptr, pStream, PtrP, pBitmap) ObjRelease(pStream) DllCall("OleAut32\VariantClear", PtrP, IStream) DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", Ptr, pBitmap, PtrP, hBitmap, UInt, 0xFFFFFFFF) DllCall("gdiplus\GdipDisposeImage", Ptr, pBitmap) Return hBitmap } }
yeah.perfect. thx.
Re: show the image of web to the gui
I have a another problem for ocring the code of dom.Could you have a try to help me ?
https://autohotkey.com/boards/viewtopic.php?f=5&t=41419
https://autohotkey.com/boards/viewtopic.php?f=5&t=41419
-
- Posts: 4365
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: show the image of web to the gui
Sorry, no idea. I can't read Chinese.
Who is online
Users browsing this forum: arrondark, Bing [Bot], Google [Bot] and 107 guests