Page 1 of 2
load Logo from Internet ?
Posted: Sun Mar 13, 2022 5:57 pm
by AUGE_OHR
hi,
is it possible to load Image from Internet and display it in IMAGE
for my IPTV i got a Logo for each TV / Radio Station like this
Code: Select all
http://logos.zattic.com/images/channels/logos/42a29350387ee5fda8fe/black/84x48.png
i try to load it this Way
Code: Select all
cImage := TRIM(FIELD->TVLOGO)
IF !EMPTY(cImage)
hBitmap := BT_BitmapLoadFile (cImage)
BT_HMGSetImage ("IPTVMAIN", "Image_1", hBitmap, .T.)
ENDIF
but this does not work
is there a Solution

Re: load Logo from Internet ?
Posted: Sun Mar 13, 2022 8:45 pm
by franco
Why not just download the image and put it in your program directory.
Re: load Logo from Internet ?
Posted: Mon Mar 14, 2022 1:26 am
by AUGE_OHR
hi Franco,
franco wrote: ↑Sun Mar 13, 2022 8:45 pm
Why not just download the image and put it in your program directory.
hm ... how under HMG

Re: load Logo from Internet ?
Posted: Mon Mar 14, 2022 7:03 am
by mol
Hi!
In my opinion, you should download logo to temporary fil.
You can use this function:
Code: Select all
PROCEDURE DownloadFromWWW
param cURL, cLocalFileName, lSilent
LOCAL oCon, oUrl, i, cResponse
local ret := .f.
local StaraObslugaBledu
BEGIN SEQUENCE with {|| break()}
cLocalFileName := alltrim(cLocalFileName)
if lSilent = NIL
lSilent := .f.
endif
oUrl := tURL():New( cUrl )
IF Empty( oUrl )
if !lSilent
MsgBox("Wrong url adress" + cUrl)
endif
BREAK
ENDIF
IF oUrl:cProto != "http"
if !lSilent
MsgBox('Wrong http adress')
endif
BREAK
END
oCon := TipClientHttp():New( oUrl )
oCon:nConnTimeout := 20000
if !lSilent
MsgBox("Connecting with "+ oUrl:cServer)
endif
IF oCon:Open( cUrl )
if !lSilent
MsgBox("Connection established." +chr(10)+"Press OK to download " + oUrl:cPath +oUrl:cFile)
endif
oCon:WriteAll(cLocalFileName)
if !lSilent
MsgBox("Downloaded and written as: "+cLocalFileName)
endif
oCon:Close()
ret := .t.
ELSE
IF oCon:SocketCon == NIL
cResponse := "Connection not initialized"
ELSEIF hb_InetErrorCode( oCon:SocketCon ) == 0
cResponse := oCon:cReply
ELSE
if !lSilent
cResponse := "Error in connection: " + hb_InetErrorDesc( oCon:SocketCon )
endif
ENDIF
if !lSilent
MsgBox("Connection can't be established: "+ oUrl:cServer+chr(10)+"Server answer: "+cResponse)
endif
ret := .f.
END
RECOVER
if !lSilent
MSGSTOP("Connection failed!")
endif
END SEQUENCE
RETURN ret
and use this function:
Code: Select all
cImageAddress := "http://logos.zattic.com/images/channels/logos/42a29350387ee5fda8fe/black/84x48.png"
if DownloadFromWWW(cImageAddress , cLocalTempFile, .t.)
hBitmap := BT_BitmapLoadFile (cLocalTempFile)
BT_HMGSetImage ("IPTVMAIN", "Image_1", hBitmap, .T.)
endif
Re: load Logo from Internet ?
Posted: Mon Mar 14, 2022 7:56 am
by AUGE_OHR
hi Mol,
mol wrote: ↑Mon Mar 14, 2022 7:03 am
You can use this function:
Thx for Sample
i do got a Image in %TEMP% with
Code: Select all
cImageAddress := "http://logos.zattic.com/images/channels/logos/42a29350387ee5fda8fe/black/84x48.png"
but it is a HTML-Error Text
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>openresty</center>
</body>
</html>
---
what do i need *.HBC
i have
Re: load Logo from Internet ?
Posted: Mon Mar 14, 2022 5:56 pm
by AUGE_OHR
hi,
have test \HARBOUR\contrib\hbtip\tests\tipwget.prg
like Demo before i got Error
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>openresty</center>
</body>
</html>
when using Firefox i can "see" Logo so it does exist
but what does this Error Message mean when File exist

Re: load Logo from Internet ?
Posted: Tue Mar 15, 2022 1:19 pm
by mol
I can't help you
Re: load Logo from Internet ?
Posted: Tue Mar 15, 2022 3:20 pm
by edk
Code: Select all
IF !File ( "84x48.png" )
MsgInfo( "Pobieranie 84x48.png ...." )
IF !PobierzPlik( "http://logos.zattic.com/images/channels/logos/42a29350387ee5fda8fe/black/84x48.png", "84x48.png" )
MsgInfo ( "Nie można pobrać pliku 84x48.png.")
ELSE
MsgInfo ( "Plik 84x48.png został pobrany." )
ENDIF
ENDIF
***********************************
FUNCTION PobierzPlik( cUrl, cFile )
Local oHttp := Win_OleCreateObject( "MSXML2.ServerXMLHTTP" )
IF File ( cFile )
hb_FileDelete ( cFile )
ENDIF
BEGIN SEQUENCE WITH {|o| break(o)}
oHttp:Open( "GET", cUrl, .F. )
oHttp:setRequestHeader( "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0" )
oHttp:Send()
IF oHttp:Status = 200
StrFile ( oHttp:ResponseBody(), cFile )
ENDIF
oHttp:Abort()
RECOVER USING oErr
MsgStop ( "Nie udało się pobrać pliku z adresu " + cUrl )
END SEQUENCE
RETURN FILE( cFile )
Re: load Logo from Internet ?
Posted: Tue Mar 15, 2022 7:26 pm
by franco
Why not Download the logo with Firefox and put in a program folder.
My one logo for desktops is called desktoplogo.jpg .... I use jpeg. I am sure you could use png.
You may need to work with it depending on size.
Code: Select all
#include "hmg.ch"
#define CRLF HB_OsNewLine()
#include "FILEIO.CH"
function Main()
DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH getdesktopWidth()-25 ;
HEIGHT getDeskTopHeight()-45 ;
TITLE "Advanced " ;
MAIN ;
NOMAXIMIZE ;
NOSIZE ;
BACKCOLOR GRAY ;
FONT 'Arial' SIZE 9
if file('desktoplogo.jpg')
define image image_1
row 10
col 10
height getdesktopheight()-110
width getdesktopwidth()-50 //-50
picture 'desktoplogo.jpg'
stretch .t.
ADJUSTIMAGE .T.
end image
endif
END WINDOW
ACTIVATE WINDOW Win_1
return NIL
Re: load Logo from Internet ?
Posted: Wed Mar 16, 2022 2:49 am
by edk
franco wrote: ↑Tue Mar 15, 2022 7:26 pm
Why not Download the logo with Firefox and put in a program folder.
My one logo for desktops is called desktoplogo.jpg .... I use jpeg. I am sure you could use png.
You may need to work with it depending on size.
Jimmy needs to fetch thumbnails from links that the user creates or import from .m3u files . These are not files permanently embedded in the program and are dynamicly changed for each selected record, therefore they must be downloaded in runtime.