forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help: Downloading images

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
youresam



Joined: 06 Nov 2005
Posts: 87

PostPosted: Fri Dec 16, 2005 8:11 am    Post subject: Help: Downloading images Reply with quote

Can anyone help me out with downloading images from the Wlan? I saw the HTTPD code and it looks a bit complicated to SEND, but to recieve it could require some more advanced coding..

If anyone has/can do this, please tell.
Thanks.
Back to top
View user's profile Send private message AIM Address
swordman



Joined: 27 Dec 2005
Posts: 27

PostPosted: Wed Dec 28, 2005 1:22 am    Post subject: Reply with quote

Hi, if you want to retive a file from the net, you need to use the HTTP protocol (or the FTP)
Simply send to the server a string like the following:
GET <path&filename> HTTP/1.1\r\n\r\n
Then wait on line end recive the data.
NOTE: I think that on PSP are needed more then
socket:recive() to obtain alla the data.
Back to top
View user's profile Send private message
youresam



Joined: 06 Nov 2005
Posts: 87

PostPosted: Wed Dec 28, 2005 2:49 am    Post subject: Reply with quote

Well, I already know how to retrieve a file, but Im saying how to build it into a PNG file. I have made a program that copies all the lines from a PNG and pastes it into a new PNG, but the PNG isnt working even though if I open it in notepad, it had the same characters. I need to download a PNG and save it.
Back to top
View user's profile Send private message AIM Address
ShUr1k3n



Joined: 16 Oct 2005
Posts: 42

PostPosted: Wed Dec 28, 2005 6:22 am    Post subject: binary mode Reply with quote

U must READ and WRITE the file in Binary Mode...

If u copy the characters the file will not be the same... Because some characters are not displayed...ETC...

In VB i use: Open "filename.extension" For Binary As #1

well... Google for it and u will find a lot of Stuff...


I hope that helps...
Back to top
View user's profile Send private message Send e-mail
youresam



Joined: 06 Nov 2005
Posts: 87

PostPosted: Wed Dec 28, 2005 6:43 am    Post subject: Reply with quote

Thanks a lot!
I found the lua.org booklet thing, and it said that you can inclue an optional 'b' for binary mode. Testing right now, will post results...

EDIT
Nope. Doesnt work. Same results when I make it read + write binary, read binary, or just write binary. Heres my code:

Code:
loadtable = ""
function load()
   file = io.open("2.png", "rb")
   if file then
      for line in file:lines() do
      loadtable = loadtable..line
      end
      file:close()
   end
end

function save()
   file = io.open("3.png", "wb")
   if file then
      file:write(loadtable)
      file:close()
   end
end

load()
save()
Back to top
View user's profile Send private message AIM Address
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Wed Dec 28, 2005 10:32 am    Post subject: Reply with quote

lines() translates newline characters, try read the whole file with read("a").
Back to top
View user's profile Send private message
youresam



Joined: 06 Nov 2005
Posts: 87

PostPosted: Wed Dec 28, 2005 1:09 pm    Post subject: Reply with quote

Ok...
So, how would I do that? I havent experimented with that abtribute yet... I mean, how would I read it or write it if I cant use variables...

Some sample code would be appreciated.

(P.S., shine, have you tried out my LUA OS yet?)
Back to top
View user's profile Send private message AIM Address
Slopey



Joined: 31 Jul 2005
Posts: 24

PostPosted: Fri Dec 30, 2005 11:05 pm    Post subject: Reply with quote

use

local data = file:read("*a")

it'll load the entire file in binary into the data variable.

There's more info at http://www.lua.org/pil/21.2.2.html on the lua site proper.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
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


Powered by phpBB © 2001, 2005 phpBB Group