Anyone a have experience with PNG chunks?

I’m trying to figure out how to store and access the chunk data in a png. The reason I’m trying to do this is to store location data/animation on sprite sheets.

I’m just doing my research but this should be possible. So, anyone have experience in this area?

Not me, but I would check out the RPGenerator project, it sounds like what youre looking for

@Briarfox Does this help any.

http://en.wikipedia.org/wiki/Portable_Network_Graphics

Thats @dave1707, I’ve been reading that, little over my head but I’ll figure it out :slight_smile:

@CodeaNoob I’m familiar with the project but I believe all the location data in stored in project.

of course, you could just write a little config file to go with the spritesheet, but maybe that’s too easy! :wink:

Alternatively, why not use (say) the top left corner of the spritesheet to store config info, encoded in bytes in the RGB values of the pixels, then you can easily read it from Codea

I had thought about that. but if I could store it in the chunk info, more room on the spritesheet. I want the data part of the sprite sheet so it can be shared easily.

Not sure if this may provide any clues, e.g. to reverse engineer or something:

http://lua-users.org/wiki/PortableNetworkGraphicsParser

Brookesi

You probably all know this, but theres a ton of interesting stuff here: http://lua-users.org/wiki/SampleCode, probably a lot of ‘requires’ required though…

Brookesi

@Briarfox Unless you’re willing to write your own png file creator, I don’t think you can stick chunks into the png file. It looks like it has a crc checksum, so anything you add has to be included in that. I think the easy solution would be what @Ignatz suggested. Write all of your information in a small png image and include that at the 1,1 position of the larger png image. Decide the maximum width and height of your image that you think will hold all of the information you’ll need in the future. It would be no problem to read that section anytime you get the png image. Besides, one small image isn’t going to take up that much room. If I did the calculations correct, a 50x50 sprite could hold the name(18 chars), x,y,w,h values of 250 other sprites. If you don’t need a name, then that jumps to 625 sprites. Of course I don’t know how many sprites to want per sheet or how big they’ll be.

@dave1707 Good point. I’m not familiar with how crc checksum works. I’ve just been reading up on png’s. Seems like you and @ignatz are right. I’ll just add the data in the image. I think it would be very useful if a spritesheet could hold it’s sprite locations and animation info.