Page 1 of 1

Loading and Image/Font from a resource file

Posted: Wed Jul 29, 2009 2:15 pm
by PauloftheWest
Is there anyway in LÖVE to create an image/font directly from data (not from a file).

So, what I'm looking for is instead of

Code: Select all

image = love.graphics.newImage(filename) 
I want something like:

Code: Select all

image = love.graphics.newImage(data, data_type) 
I've already implemented reading/writing from an encrypted resource file, it is very quick and easy. The thing is I can only return the data of the image/font/whatever.

I could create a temporary file, write the data into it, and then load it from that, but that seems more complicated and wasteful then it should be.

Why am I loading from a resource file? Well, long story short, the license we have for the game basically requires it...

Thanks,

~PauloftheWest

Re: Loading and Image/Font from a resource file

Posted: Wed Jul 29, 2009 4:28 pm
by Robin
Don't hold your breath. I don't think the devs will implement it for 0.6.0 (or ever), so, I guess you'll have to make a temporary file anyway...

Re: Loading and Image/Font from a resource file

Posted: Thu Jul 30, 2009 3:43 am
by bartbes
fail! thats exactly what weve done

[@psp]

Re: Loading and Image/Font from a resource file

Posted: Thu Jul 30, 2009 2:03 pm
by PauloftheWest
Where is the documentation? I haven't seen it in tutorials or wiki.

Where are the definitions for the constants for the different data type (.PNG, .JPG, etc)?

~PauloftheWest

Re: Loading and Image/Font from a resource file

Posted: Thu Jul 30, 2009 4:25 pm
by Robin
I think I have an anti-telepathic connection with the dev team. :P

That might also be why bartbes and I sometimes have so much trouble understanding each other. :ehem:

@PotW: it might take a while before they make the documentation (rude's apparently thinking about using an automatic documentation generator).

Re: Loading and Image/Font from a resource file

Posted: Thu Jul 30, 2009 4:27 pm
by bartbes
its in the svn, maybe rude or mike can explain some more

edit: at the same time robin was writing

Re: Loading and Image/Font from a resource file

Posted: Thu Jul 30, 2009 9:10 pm
by PauloftheWest
Ah, I see. Well that makes sense that there isn't any documentation since it is only in the repository.

For automatic documentation I've found luadoc to be useful: http://luadoc.luaforge.net/.

I didn't see the svn repository earlier. I'll look through the code and see what I can come up with.

Doing some searches, I noticed http://love2d.org/wiki/index.php?title=Version_0.6.0 which does outline that you can create an Image directly from ImageData. The only two constructors I saw for ImageData (in the source) were passed a file, or passed dimensions. Unfortunately, the data in my game is not stored in a raw format, it is stored in .png. Hence I don't know the dimension, much less the rgb, unless I decoded it myself.

Thanks!

~PauloftheWest