Loading and Image/Font from a resource file

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
PauloftheWest
Prole
Posts: 15
Joined: Mon Jul 20, 2009 4:31 pm
Location: Ravenel, SC

Loading and Image/Font from a resource file

Post 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
Last edited by PauloftheWest on Wed Jul 29, 2009 5:14 pm, edited 1 time in total.
~less think, more do
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Loading and Image/Font from a resource file

Post 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...
Help us help you: attach a .love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Loading and Image/Font from a resource file

Post by bartbes »

fail! thats exactly what weve done

[@psp]
User avatar
PauloftheWest
Prole
Posts: 15
Joined: Mon Jul 20, 2009 4:31 pm
Location: Ravenel, SC

Re: Loading and Image/Font from a resource file

Post 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
~less think, more do
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Loading and Image/Font from a resource file

Post 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).
Help us help you: attach a .love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Loading and Image/Font from a resource file

Post by bartbes »

its in the svn, maybe rude or mike can explain some more

edit: at the same time robin was writing
User avatar
PauloftheWest
Prole
Posts: 15
Joined: Mon Jul 20, 2009 4:31 pm
Location: Ravenel, SC

Re: Loading and Image/Font from a resource file

Post 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
~less think, more do
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 228 guests