Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 900 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
load image from a website #457751
01/29/16 15:27
01/29/16 15:27
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Hey there,

I'm trying to load an image from a website. I already tried
acknex's http_-functions but it doesn't really work. http_result
returns the correct size of the recieved data (exactly the same
as the image), however, the string in which the received data
is stored only contains the image's header; it doesn't seem to
contain the rest of the file.

Maybe someone knows how to do this properly?


POTATO-MAN saves the day! - Random
Re: load image from a website [Re: Kartoffel] #457752
01/29/16 16:16
01/29/16 16:16
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
How do you display the byte array?
It sounds like you displayed it like a string using a MessageBox?
A string is cut off when it reads the nullterminator which is a plain 0

Re: load image from a website [Re: Ch40zzC0d3r] #457753
01/29/16 16:25
01/29/16 16:25
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
I save it into a text file using a loop (maximum is the size which http_result() returned) and file_asc_write.

This is the result:


Top is received, bottom is the original image (in this case the a8 logo for testing)

as you can see, the string doesn't receive all the data. so file_asc_write is writing some data from the ram that is located after the string.


POTATO-MAN saves the day! - Random
Re: load image from a website [Re: Kartoffel] #457754
01/29/16 17:11
01/29/16 17:11
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
You should use a proper hex editor to see at which byte its failing.
Also please post some code, I never used the engines http stuff.

Re: load image from a website [Re: Ch40zzC0d3r] #457758
01/29/16 19:56
01/29/16 19:56
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Looks like the problem is the http_result() function.
It stops writing data into the target string after what seems to be some special character.
...which means there's most likely no possible workaround.


POTATO-MAN saves the day! - Random
Re: load image from a website [Re: Kartoffel] #457759
01/29/16 20:02
01/29/16 20:02
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Well, if you would offer some more infos Im sure we can find a workarround for you.
If everything fails you can use winapis (sockets) to obtain the data.
Easiest workarround for now seems to be Base64 encoding.

Last edited by Ch40zzC0d3r; 01/29/16 20:03.
Re: load image from a website [Re: Ch40zzC0d3r] #457761
01/29/16 20:37
01/29/16 20:37
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
I offered pretty much all there is to know confused

- I'm using http_sendpost to get an httpID
- I use http_result to write the received data into a string

That's all


POTATO-MAN saves the day! - Random
Re: load image from a website [Re: Kartoffel] #457766
01/29/16 21:23
01/29/16 21:23
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Well, http_result returns a string.
I guess it simply stops after reading 0x00, you can simply use base64 encoding and your problem is solved.

Re: load image from a website [Re: Ch40zzC0d3r] #457767
01/29/16 21:30
01/29/16 21:30
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
But I don't think I can force a website to send the requested file as base64 encoded data smirk
I'm not trying to load file from my website, but from another.


POTATO-MAN saves the day! - Random
Re: load image from a website [Re: Kartoffel] #457769
01/29/16 21:47
01/29/16 21:47
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
You can make your own script which receives the link as parameter and returns the content as base64. Otherwise just use winapis / sockets

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1