Slick Forums

Discuss the Slick 2D Library
It is currently Sun Nov 19, 2017 2:55 am

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: [IDEA] Serializable Data
PostPosted: Wed Jun 13, 2012 10:42 am 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
I thought about this, should we add some way to make saving images easy? I think of doing it like List implementation do it. We load the relevant data by override the write/read method and make texture data and all the low level stuff transient. So on read we try to load the stuff by writing the path to the image file and so on.

It's not something small but let's just consider the ups and downs here :D

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
PostPosted: Tue Jun 26, 2012 2:24 pm 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
That would be one way, or we make the Slick Images implement java.awt.image.RenderedImage ... then we could use javas ImageIO... and that would be awesome.

Nitram

_________________
http://illarion.org


Top
 Profile  
 
PostPosted: Tue Jun 26, 2012 2:53 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
No this is not a good idea. Do you really want to SAVE and image... e.g. if you make a save game? I guess you want to have the reference and load the image if needed :)
That's why I did not suggest directly saving an image :D

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
PostPosted: Wed Jun 27, 2012 9:09 am 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
Would be a nice way to save Screenshots. Just saying. :wink:

Other then that, I don't really consider something like this as useful. If you load the image using the reference to a file or by deserializing it, is not a real difference, except the point that you need to store additional data in the image, like the file it was load from. (and only in this case it can be deserialized), because you need to reload this file in order to fetch the image data from the filesystem/classpath again. If you created the image as subimage or by referring to a otherwise created texture object, you have close to no chance to perform a proper deserialization.

Only exception would be if you actually serialize the texture data that is stored in OpenGL. But there we are again at saving the image.

Nitram

_________________
http://illarion.org


Top
 Profile  
 
PostPosted: Wed Jun 27, 2012 10:18 am 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Texture wouldn't be a problem. Image is a wrapper anyway and most data is already serializable. texture most be transient and the override of the load method from the serialization most load this texture (InternalTextureLoader does the rest at not loading two textures twice and such) :)

For screenshots there is a nice little way MatthiasM provided somewhere and if oyu want to do it on your own. Just have a texture where you copy all the pixels to (Slick does somehting like that already).

But yeah, it just was an in idea. As you said you can easily do it on your own:)

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
PostPosted: Wed Jun 27, 2012 12:05 pm 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
I thing I do not understand is:
What is the purpose of serializing the image if its impossible to deserialize the image without ensuring that the texture loader supplies the exact same texture again.

I see nasty problems and confusion rising here if that is implemented. Sure many things are serializable but without a way of ensuring that the image is recreated properly it will remain a problem.

Nitram

_________________
http://illarion.org


Top
 Profile  
 
PostPosted: Wed Jun 27, 2012 1:06 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
The idea is to hae the ability to save everything through Java Srialilization :) Cas does this with Revenge of the Titans e.g.. I never said it would be easy (as you can see in my start post) but I just thought :"Hey, why not suggest things instead of sitting around wating for davedes to push something" :D

I'm also waiting on respones on the pausing in StateBasedGame. Until next week I wait. If no one has something against it, I just do it.

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
PostPosted: Wed Jun 27, 2012 5:08 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
My 2c
- We already use PNG/TGA/etc formats to serialize image data.
- What about consistency with all other asset types? Sounds, sprite sheets, etc?
- What's the purpose? How will the code changes benefit users? Is it worth the time and effort? Keep in mind that (generally speaking) adding new things introduces new bugs and problems.

These kind of things may be better envisioned as an extension, rather than changing the Slick lib. It's very easy to set up a github project, and we could even link to it in the wiki.

For example, I have a "PixelData" utility that I'm not sure is really needed for Slick, but I figured it's important enough to mention it in the wiki:
http://slick.cokeandcode.com/wiki/doku. ... ta_utility


Top
 Profile  
 
PostPosted: Wed Jun 27, 2012 5:54 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Again, as said. This was just an idea. Or better a question. I would not use it, but I can see people using it :)

So I guess cased closed...? :D

btw. nice PixelData class.

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
PostPosted: Tue Jul 17, 2012 3:04 am 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 598
Nitram wrote:
Would be a nice way to save Screenshots. Just saying. :wink:


Maybe I'm not understanding; but it's fairly easy to do screenshots with slick. I do it like this:

Code:
Image target = new Image(app.getWidth(), app.getHeight());
Graphics g = app.getGraphics();
g.copyArea(target, 0, 0);
ImageOut.write(target, screenShotFileName, false);
// needed?
// target.flushPixelData();
target.destroy();


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group