Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Streaming jpg from web to image control
Message
General information
Forum:
Visual FoxPro
Category:
Pictures and Image processing
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01641394
Message ID:
01641417
Views:
110
yes you can with this prototype code below
*this code can load a web image from a vfp9 form.it uses the  MsXml2.XmlHttp object protocoles
*the responseBody returns a blob as image representation and uses the pictureVal property to display it
*note this is done without saving the image on disc and loading it as usual vfp method.
*the responseBody is a blob string loaded in memory.
*of course internet must be connected
*As you can see its fast and maybe never one used this trick before ?

Publi yform
yform=Newobject("yWebimg")
yform.Show
Read Events
Retur
*
Define Class ywebImg As Form
	Height = 389
	Width = 976
	ShowWindow = 2
	ShowTips = .T.
	AutoCenter = .T.
	Caption = "Display  directly web images without saving them on disc"
	MaxButton = .F.
	BackColor = Rgb(0,0,0)
	Name = "Form1"

	Add Object image1 As Image With ;
		Stretch = 1, ;
		Height = 377, ;
		Left = 360, ;
		Top = 7, ;
		Width = 612, ;
		Name = "Image1"

	Add Object edit1 As EditBox With ;
		Height = 288, ;
		Left = 1, ;
		ReadOnly = .T., ;
		ToolTipText = "Blob representation", ;
		Top = 82, ;
		Width = 275, ;
		ForeColor = Rgb(128,0,64), ;
		BackColor = Rgb(255,255,185), ;
		Name = "Edit1"

	Add Object combo1 As ComboBox With ;
		Height = 24, ;
		Left = 0, ;
		ToolTipText = "Add any web image url here ", ;
		Top = 24, ;
		Width = 276, ;
		Name = "Combo1"

	Procedure Destroy
	Clea Events
	Endproc

	Procedure combo1.Init
*add all wanted web images below with valid url
	With This
		.AddItem("https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcR9MW3nZFBOsjrmUM50lWgwx82B43qtj0D8Hvl6qf_vDetuUH3pSQ")
		.AddItem("http://www.dknews-dz.com/data/images/article/thumbs/d-el-bayadh-labsence-de-bureaux-detudes-agrees-retarde-linventaire-du-patrimoine-culturel-immobilier-acbf4.jpg")
		.AddItem("http://www.algerie-monde.com/hotels/el-bayadh/ksar-boussemghoun-el-bayadh.jpg")
		.AddItem("https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRRNxGZNoINi9pJwvFVTVnDdlvZVIynziEO2YVA9PN6sdV5_EDL")
		.AddItem("http://img.over-blog-kiwi.com/100x100-ct/1/43/54/07/20150121/ob_249909_yben.JPG")
		.Style=2
		.ListIndex=1
		.Click()
	Endwith
	Endproc


	Procedure combo1.Click
	Thisform.edit1.Value=""
	Local loRequest,lcUrl

	m.lcUrl=This.Value
	m.loRequest = Createobject('MsXml2.XmlHttp')
	m.loRequest.Open("GET",lcUrl,.F.)
	m.loRequest.Send()
	Thisform.image1.PictureVal=m.loRequest.ResponseBody
	Thisform.edit1.Value      =m.loRequest.ResponseBody
	m.loRequest=Null
	Endproc


Enddefine
*
*-- EndDefine:ywebImg
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform