I am working on a project that uses a web service to extract a PNG image from a web server and save it on a local machine. It's done via a system call. I can get the output of the system call to a FILE but it appears to be losing data, most notably the PNG chunk names (IHDR/PLTE/IDAT/IEND, notably). (Unfortunately piping the output to an exterior file does not work through a system call.) The end result is ~6KB smaller than the file I am intending to retrieve.
This is the code I'm using (adapted from other material I found via searches here):
@ne555: That might be an issue as well. I haven't done a full file comparison but there's enough missing that '\0's are probably being blocked out as well. Maybe I'll try using read()...
@DTSCode: All I want to do is copy the file returned from the web surface to a local file; I don't want to display it or anything like that. Can I do that with SDL? (I'm a bit of a novice when it comes to image processing.)
while(!feof(fp)) is wrong (it is pointless to test for input errors before the input is even attempted!) responseString += a; stops at the first zero found in a
If I understand correctly the OP just want to transfer a PNG file from a web server to the local machine. You don't need any PNG-specific code for doing that.
If I understand correctly the OP just want to transfer a PNG file from a web server to the local machine. You don't need any PNG-specific code for doing that.
Exactly this. Just looking at some of the SDL stuff it doesn't look like where I want to go.
The service returns the contents of the PNG file itself, so ideally I just want to copy that and save it to a file.
@Cubbi: Would it be better to use a char [] array instead?