Author Topic: PNG Manipulation Tool Used For AVWW (free and open source, source attached).  (Read 6499 times)

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Thought I'd cross-post from here: http://www.arcengames.com/forums/index.php/topic,8546.msg75823.html#msg75823

Will the sprite dictionary also be used for the animated effects? (if so i do hope you release your gdi tool to align the single sprite png's... ;p)

I forgot to mention, but yes, all the sprites in the game are now in sprite dictionaries -- it saves even more RAM, VRAM and texture swaps with them, since usually you have many in a row that are at various stages of animation.  Bear in mind I'm talking here about the individual particles exported from particle illusion that are used to make compound effects, not the actual compound effects themselves, of course.  The main component of the fireball effect, with all its frames, is attached as one example (it's a two-image sprite dictionary).

I don't mind at all sharing the tool and the code for it, I've thought about doing just that, but the main problem is that it's really specific  to my needs at the moment; it only does dictionaries in powers of two images, and it prefers to do two smaller images (say, two 512x512 images) instead of one larger image (one 1024x1024 image) when it can, since the total number of pixels quadruples each time you go up a size, and that wastes more RAM and disk space, ultimately.  This whole thing also only works with PNGs, because that's all I needed; it's not a general-purpose tool.  It also requires .NET 2.0.

Anyway, I've attached both the executable and the source code in two attachments here, so you're welcome to them if you want.  A few other notes:

1. Min Combine Size sets the minimum size of dictionary frames it will use.  So if your frames are actually 30px large at the largest, but you want them centered in 64px for some reason (I had to do this with the side-facing bat poses, for instance), you can set 64px and then the frame sizes will match those of your other stances, for instance.

2. To do the dictionary, hit Process Combine once you've put in a directory (when you click the textbox, it automatically pastes from the clipboard, to save some keystrokes).  It's nondestructive, in that it will put in some new images based on your existing PNGs.

3. Scale Character will scale and entire folder larger sprites down to the size set in the Scale To textbox.  It analyzes the entire non-transparent width/height of all the sprites in that folder when determining what offsets to place each one at in the reduced images.  That's what I was talking about above for the characters, for instance.  This is a destructive process -- it alters your existing images, so make sure you have a backup before you do this!  I always run it on a secondary folder I've created just for that purpose.

4. Process Rename is what my original function of this program was, and it just looks in a folder and renames all the files to be FolderName.png, FolderName2.png, FolderName3.png, etc.  This is handy when converting from the number format from one program (they are all different) to the specific format I was using before I started doing sprite dictionaries (thus making this no longer really needed).

5. Process Duplicate is identical to Process Rename, except that it also duplicates all of the frames in a series except the first and last, in reverse order.  So if you have frames 01234556789, and really you need that to loop in a specific fashion in a dictionary, you can use Process duplicate and not only will it do what Process Rename does, but it will also duplicate things so that your sequence is 012345678987654321, and then it's ready to loop again at 0 seamlessly.

So hope that's of some help, but bear in mind it's not a general-purpose tool at the moment (though the source code is there, so folks can do with that what they will).
« Last Edit: May 07, 2012, 06:41:54 pm by x4000 »
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline eRe4s3r

  • Core Member Mark II
  • *****
  • Posts: 2,825
Thanks this is much appreciated ;)

Seems to work just fine with 1024x1024 too... ;)
« Last Edit: April 12, 2011, 04:59:03 pm by eRe4s3r »
Proud member of the Initiative for Bigger Weapons EV. - Bringer of Additive Blended Doom - Vote for Lore, get free cookie

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
My pleasure! And yeah, it will do any power of 2 resultant dictionary up to 1024. :)
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Here's the latest version of the tool, which includes a few other neat tricks in it.
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline eRe4s3r

  • Core Member Mark II
  • *****
  • Posts: 2,825
thats really weird, all i get is a index.php

PHP Script (-1 Bytes)

Firefox 8 issue?
Proud member of the Initiative for Bigger Weapons EV. - Bringer of Additive Blended Doom - Vote for Lore, get free cookie

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Must be something on FF8, I guess -- I'm on FF7 with no issues.  The direct link is: http://www.arcengames.com/forums/index.php?action=dlattach;topic=8548.0;attach=4252
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline eRe4s3r

  • Core Member Mark II
  • *****
  • Posts: 2,825
Funnily i got an 27kb index.php from that -1 byte php which after being renamed to bla.zip actually contained what i downloaded.. thats one hell of an issue ;p
Proud member of the Initiative for Bigger Weapons EV. - Bringer of Additive Blended Doom - Vote for Lore, get free cookie

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Yeah, that's very strange!  Hopefully that gets worked out by the FF8 team, or the SMF team.
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline eRe4s3r

  • Core Member Mark II
  • *****
  • Posts: 2,825
Seeing as this topic is now really old but this tool is still really cool i was wondering whether i could get some quick explanation on what the new functions in v2 do?

1024 MAX Series
OVERLAY from Template
TRANS GRID
DEL ALTERNATING
9up and Scale
Scale and Trim (only useable in conjunction with Min Combine size i assume?)

I know this has like 0 priority right now but i'd still be curios, from my testing i only got mediocre results, so i assume it does something particular for character animation, also what does "scale to" do when you already set Min Combine size, min combine size centers it, so does scale-to define how large a frame should be or how large a frame-set should be? Reason i am asking here is that i already had this figured out once and forgot it all again, and now i can't even remember what button to press without breaking something.. argh ;/
« Last Edit: January 09, 2012, 03:38:13 am by eRe4s3r »
Proud member of the Initiative for Bigger Weapons EV. - Bringer of Additive Blended Doom - Vote for Lore, get free cookie

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
"1024 MAX Series" takes a larger image of whatever size -- say, 4096x2048 -- and then breaks it into 1024px-at-most chunks.  So the prior example would lead to 8 1024px square images, for instance.  I use this to take super-large buildings and split them up into pieces that the game can automatically reassemble without any issues on any graphics card.

"OVERLAY from Template" was kind of an experimental thing I was doing, I think.  It looks in the folder of the file you specify for a "template.png" file, and then overlays that into the file you specified.  It was just a quick way for me t combine two files, and I forget why I needed it -- something about the pixel math is different from what I could do in Photoshop, I seem to recall, but again I think this was mostly experimental and not something I really finished out.

"TRANS GRID" makes a patchwork of transparent holes in a texture.  This turned out not to be useful either, but was something I was experimenting with.  Back in the DirectDraw7 days and before, you had to do this sort of thing to have "transparent" water or windows, for example.  And I thought I'd give that a shot with one effect I was going for.  Didn't work as hoped visually, although the actual concrete trans grid function works as advertised.

"DEL ALTERNATING" deletes every second image in a folder.  This is useful when you've got some really high-FPS animation that you want to halve the FPS of manually, without actually removing every other frame by hand.

"9up and Scale" takes in the image you specify, and creates a perfect tile of 9 of them, each of them scaled to whatever you specify.  I use this quite a bit before I post-process large background tiling images, because Photoshop leaves artifacts at the edge of the images in a way that doesn't tile properly.  With this, I can hit "9up and Scale" and then do my post-processing on that image in photoshop, then crop the image down to the center of the 9 copies of itself and save that out.  Bingo -- perfect tiling.  The algorithm in "9up and scale" wraps pixels around the edges, whereas Photoshop treats each boundary of the image as a hard border in most filters (thus blending pixels near to that border with transparent pixels, rather than the pixel on the mirror side of that image).

"Scale and Trim" works like you'd think, except that it centers the image rather than orienting it at the bottom center like the character one does.  I use this for particle effects instead of characters/monsters.
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline eRe4s3r

  • Core Member Mark II
  • *****
  • Posts: 2,825
Thank you ;)
Proud member of the Initiative for Bigger Weapons EV. - Bringer of Additive Blended Doom - Vote for Lore, get free cookie

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
My pleasure!  Hope it's useful. :)
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
FYI, both the actual compiled program and the source have been updated in the original post.  The new version is more efficient and supports non-square textures (but still power of two on all sides), as well as a few new functions.
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!