Computer Science Canada

Having problems downloading pictures of the net

Author:  Homer_simpson [ Sat Apr 19, 2003 2:17 am ]
Post subject:  Having problems downloading pictures of the net

code:
var url : string
url := "http://www.geocities.com/stmxpm/finaly.jpg"
var netStream : int
var f : int
var ch : char
netStream := Net.OpenURLConnection (url)

open : f, "c:/downloaded file.jpg", write
loop
    exit when eof (netStream)
    get : netStream, ch
    write : f, ch
    %put ch
end loop
Net.CloseConnection (netStream)
close (f)
ok that's the code and it's supposed to download a jpg file off this address "http://www.geocities.com/stmxpm/finaly.jpg". well .... it downloads somethink and it's a picture but when i open it it's a whole new picture.

Author:  Homer_simpson [ Sat Apr 19, 2003 2:21 am ]
Post subject: 

when i use the program download bmp files it seems to work fine but it has a problem with all jpgs.
code:
var url : string
url := "http://www.geocities.com/stmxpm/sc1.bmp"

var netStream : int
var ch : char

netStream := Net.OpenURLConnection (url)
if netStream <= 0 then
    put "Unable to connect to ", url
    return
end if
var f : int
open : f, "c:/downloaded file.bmp", write
loop
    exit when eof (netStream)
    get : netStream, ch
    write : f, ch
    %put ch
end loop
Net.CloseConnection (netStream)
close (f)

anybody knows how to solve the problem?[/code]

Author:  jamez [ Sat Apr 19, 2003 7:25 am ]
Post subject: 

I made it able to download JPGs but it really screws up the pic.

code:
var location : string := ""
put "http://" ..
get location
location := "HTTP://" + location

var ch : char
var netStream : int := Net.OpenURLConnection (location)

if netStream <= 0 then
    put "Image does not exist."
    return
end if

put "Saving..."

var file : int
open : file, "C:/DownloadedImage." + location (length (location) - 2 .. length (location)), write
loop
    exit when eof (netStream)
    get : netStream, ch
    write : file, ch
end loop
Net.CloseConnection (netStream)
close (file)

locate (2, 1)
put "Image saved."

Author:  Blade [ Sat Apr 19, 2003 9:36 am ]
Post subject: 

well... i dunno if any of you guys ever had this problem, but when i was making a game, i could NOT use jpg's... i always had errors no matter what i did with it...but was fine with bmp's... could be a flaw in turing...

Author:  Catalyst [ Sat Apr 19, 2003 11:12 am ]
Post subject: 

jpgs are only in 4.0x they wont work if u use 3.11

Author:  Blade [ Sat Apr 19, 2003 12:04 pm ]
Post subject: 

i use 4.0.4c

Author:  Homer_simpson [ Sat Apr 19, 2003 12:45 pm ]
Post subject: 

that's exactly my problem too i can download bmps but when i download jpgs they get screwed up Confused =/


: