FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log inLog in 


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

Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog Tips & Samples
View previous topic :: View next topic  
Author Message
Gildas Menier




Joined: 08 Jun 2004
Posts: 210

PostPosted: 28 May 2006 20:40    Post subject: (Howto) get an image from internet and display it (and more) Reply with quote

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/Community/userExamples/htmlToList.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)



vp_web.jpg
 Description:
 Filesize:  81.28 KB
 Viewed:  7767 Time(s)

vp_web.jpg



test_vp_web.zip
 Description:

Download
 Filename:  test_vp_web.zip
 Filesize:  89.54 KB
 Downloaded:  1208 Time(s)

Back to top
View user's profile Send private message
drspro2



The Netherlands
Joined: 28 Apr 2006
Posts: 168

PostPosted: 20 Aug 2011 10:18    Post subject: Reply with quote

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

% 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),
    !.%
   */

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog Tips & Samples All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum