(Howto) get an image from internet and display it (and more)

Share Tips, Code Samples, etc. with the Visual Prolog community.
Post Reply
Gildas Menier
Active Member
Posts: 78
Joined: 8 Jun 2004 23:01

(Howto) get an image from internet and display it (and more)

Unread post by Gildas Menier » 28 May 2006 20:40

This project shows how to download a web page, parse it to extract the <img> tags (thanks to a code made by Mr Yasuhisa Matsumura and available in the examples of visual prolog). Then how to download a picture (given its URL) and make a gdi image from it and display it.

The project contains a very small subset of predicates to call wininet. This should work for CE and PE.

The code from Mr Yasuhisa Matsumara can be found there http://www.visual-prolog.com/vip6/Commu ... ToList.htm

regards

Gildas

- I try to keep my codes up to date there http://www.arsaniit.com, so feel free to tell me if it needs a fix or two.
- these dogs don't belongs to me. Thanks god (or sknahT dog)
Attachments
vp_web.jpg
vp_web.jpg (81.28 KiB) Viewed 8646 times
test_vp_web.zip
(89.54 KiB) Downloaded 1285 times

drspro2
Active Member
Posts: 119
Joined: 28 Apr 2006 12:03

Unread post by drspro2 » 20 Aug 2011 10:18

I believe that the following modification should be made to make it possible to read longer url-strings

Code: Select all

% new         getURLContentAsBin(URL) = Res :-           IT   = vp_web::internetOpenws(),           FIT = vp_web::internetOpenUrlWs(IT,URL),           binres := binary::createAtomic(0),           sz := 0,           programControl::repeat,               Temp = binary::createAtomic(bufferSize),               Remain = vp_web::internetReadFile(FIT, Temp, bufferSize),                     sz:=sz+Remain,                     Temp2 = binary::reSize(Temp,Remain),                     binres := binary::concat(binres, Temp2),          Remain = 0,          vp_web::internetClosehandle(FIT),          vp_web::internetClosehandle(IT),          Res = binary::reSize(binres,sz),     !.     /* Old       getURLContentAsBin(URL) = Res :-           IT   = vp_web::internetOpenws(),           FIT = vp_web::internetOpenUrlWs(IT,URL),           binres := binary::create(0),           sz := 0,           Temp = binary::create(bufferSize),           programControl::repeat,               Remain = vp_web::internetReadFile(FIT, Temp, bufferSize),               sz:=sz+Remain,               binres := binary::concat(binres, Temp),           Remain = 0,          vp_web::internetClosehandle(FIT),          vp_web::internetClosehandle(IT),          Res = binary::resize(binres,sz),     !.%    */

Post Reply