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 

Load Image from Array of Bytes

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



Joined: 02 Jun 2006
Posts: 4

PostPosted: Fri Jun 02, 2006 1:29 am    Post subject: Load Image from Array of Bytes Reply with quote

Hi all!
Exist a way to load a jpeg Image from Array of Bytes?
I try to save the array to file and after load image from file.
This method is sloooow!
I get this array from wi-fi! The time to get this array from pc is very speedly (1sec.) but the save to file is slow(10-20 sec.)
If is possible load a jpeg image directly from an Array of Byte (the time is speedly (1sec + load from array).

My Code is:
Code:
myArrayofImage = ""
...
myArrayofImage = myArrayofImage .. socket:recv()
...
file = io.open("img.jpg","wb")
file:write(myArrayofImage)
file:close()
...
myImage = Image.load("img.jpg")


This method is sloooow!
You know a method for don't save the image to file??
Thanks in advace!!

Stefano Russello (Creator of PSP Brew B) )
Back to top
View user's profile Send private message
romero126



Joined: 24 Dec 2005
Posts: 200

PostPosted: Sat Jun 03, 2006 5:19 am    Post subject: Reply with quote

cant say that I do, however if your good with elf binaries i could probably give you some code that might help.
Back to top
View user's profile Send private message
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Sun Jun 04, 2006 4:26 am    Post subject: Re: Load Image from Array of Bytes Reply with quote

puffo83 wrote:
Exist a way to load a jpeg Image from Array of Bytes?


Yes, see the release notes of Lua Player 0.20.
Back to top
View user's profile Send private message
puffo83



Joined: 02 Jun 2006
Posts: 4

PostPosted: Mon Jun 05, 2006 7:42 am    Post subject: Re: Load Image from Array of Bytes Reply with quote

Shine wrote:
Yes, see the release notes of Lua Player 0.20.


Creating an image from array of bytes is a new features of new Lua Player 0.20??
Really???
Back to top
View user's profile Send private message
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Mon Jun 05, 2006 7:55 am    Post subject: Re: Load Image from Array of Bytes Reply with quote

puffo83 wrote:
Creating an image from array of bytes is a new features of new Lua Player 0.20??
Really???


Yes, see http://forums.ps2dev.org/viewtopic.php?t=5885 . Maybe this will be useful later when integrating physfs, too, which will allow packing all files of a game in one zip file.
Back to top
View user's profile Send private message
romero126



Joined: 24 Dec 2005
Posts: 200

PostPosted: Mon Jun 05, 2006 1:11 pm    Post subject: Reply with quote

any Possibility of image scaling next version?
Back to top
View user's profile Send private message
puffo83



Joined: 02 Jun 2006
Posts: 4

PostPosted: Mon Jun 05, 2006 5:21 pm    Post subject: Reply with quote

Great work Shine!!
Works perfectly now!
The speed is superrrrrr!!! :D


new function Image.loadFromMemory for loading images from memory:
Code:

Code:
     jpegFile = io.open("test.jpg", "rb")
     data = jpegFile:read("*a")
     jpegFile:close()
     image = Image.loadFromMemory(data)



PNG and JPEG is supported and autodetected
Back to top
View user's profile Send private message
MikeHaggar



Joined: 18 Jul 2005
Posts: 116

PostPosted: Tue Jun 06, 2006 2:25 am    Post subject: Reply with quote

Hmm... How bout adding this for sound & music too?
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