[Tool]Snip'n'Stitch v4

Ask questions, discuss ideas, get answers
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

[Tool]Snip'n'Stitch v4

Post by Senshi »

In various recent threads the topic has come up that the old trusty tgasplit etc. tools have their considerable limitations for comfy and regular use as needed for advanced terrain texturing in external editors.

While I no longer actively mod, I still remember that I had a lot of issues with those tools as well and it annoyed me vastly. When fook contacted me the day before yesterday, having again issues with tgasplit, I decided to follow the modder's creed: If it doesn't exist, do it yourself.

So, I present you a new tool, which I label "Snip'n'Stitch". It is a lightweight Java app that will be able to SNIP images into predefined segments and also will be able to STITCH a set of images together into a new image.

Image

The number of segments for width/height can differ (should you need that for whatever reason. Probably not helpful for terrain editing, but I like to keep my apps as open and multifunctional as possible). Using "bad" divisors that require uneven cuts (e.g. splitting a 100x100 image into 7 segments) will lead to a row/column of pixels being MISSING somewhere, so get your math right.

"Naming scheme" allows you to customize your desired output segments' names. For this there are two predefined pointers, {x} and {y}. Place these inside the name scheme, and they'll be used to count the segment indices.
For Battlefield 1942, the naming scheme would look like this: "Tx{x}x{y}".

"Leading zeros" allows you to specify the number of leading zeros you want the indices to have. E.g. Battlefield terrain textures start counting at "Tx00x00". This means that you will require 2 leading zeros so the segments match up the name.
Another example (the one I use for the tooltip as well)
The number of leading zeros used for {x} and {y}. A value of 3 means:"
2 will be labeled as "002"
22 will be labeled as "022"
222 will be labeled as "222"
2222 will be labeled as "2222"

Planned features
  • Warning when a desired segmentation leads to impure cuts (segment width with decimal pixel values).
  • Impure cuts should not lead to missing pixels, but rather the questionable row should be filled with the nearest neighbour value (or black) to retain original image size in segments.
  • Support for more image formats (DDS won't come, sorry, but there's just no proper Java API for that).
Example with 2x3 segmentation

The tool is still far from being finished, but as fook requires this "ASAP", I decided to push a first release with the current limited featureset (call it beta, if you will).

INSTALLATION
1: This tool is a java app. This means that you HAVE to have Java 7 installed.
2: This tool is Multi-OS and uses the native OS GUI. Currently it supports both 32bit and 64bit Windows as well as 32/64bit Unix/Linux-based OS. OSX might come in the future.
3: As it's a java app, there is no installation. Simply extract the archive and doubleclick the ".jar". If for whatever reason this does not work on your PC, I also added a comfy "start.bat" that runs the proper launch command on the .jar. This is just a failsafe and can be deleted if double-click works.
4: If you REALLY want to save a couple of MB, you can delete all the ".jar" files inside the lib that do not fit your OS. This might be automatically done by an installer in the future...

USAGE
Self-explanatory, I think. Hover over customizable fields to get a helpful tooltip if you need it.
Take not that the "SNIP" button only becomes active once you have filled in all necessary values. The naming scheme for example must contain both the {x} and {y} variable somewhere.
All settings will be stored in a local file in the same folder (settings.properties) and be automatically restored whenever you launch the tool again.

DOWNLOAD VERSION 4



Changelog
v4 - 09.Jun 13
  • Settings.properties renamed to settings.txt to make it clear it's a simple editable text file. If you still have the .properties file, either delete it or rename it to .txt to transfer settings.
  • Missing settings no longer lead to crash on startup (the file can be missing completely, and as such is no longer included in the distribution).
  • Stitch feature added. This feature allows to specify an input directory containing your segment images. By defining the pattern in which the X/Y directions are included in the filenames, the tool will arrange the the images according to that and generate/save a mosaiced image.
    For the XY detection to work, you need to specify the naming pattern by using the two variables <*x> and <*y>. The tool will search your image filenames for occurences of these and understand it. The way it currently works is:
    The number of leading zeros doesn't matter at all, so using the scheme Tx<*x>x<*y> will fit and be understood for all the following file names.:
    Tx001x114
    Tx1x114
    Tx00000001x114
    After selecting an input folder and a valid naming pattern, you also will get a preview of how your stitched image will look like.
  • Changelog shows when informing about version update
v3 - 25.Mar 13
  • Program no longer fails to start if no imgin in the settings.properties is specified (draws dummy image instead)
  • Fixed bugs with the scroll bars of the preview image, practically making them useless and messing up the preview for big images.
  • Fixed bugs with resizing the preview image (related to above, mostly)
  • Added a start.bat again for convenient launch on systems with faulty jarfile registry entries.
  • Reads TGA files now. No write (as TGA is a deprecated image format, there never will be write support).
  • KNOWN BUG: Do NOT delete the settings.properties. Missing settings for "leadzero" and "naming" will cause the program to FAIL to start up. Will be fixed in a next version...
v2 - 13.Jan 13
  • Preview for snip, showing the resulting cut lines directly on top of the input image.
  • Automated check for new versions (yay). If an update exists, a popup will allow you to get a direct download link to the new 7z archive. No self-updater (yet?), sorry.
v1 - 10.Jan 13
  • First release (only includes "Snip" feature)
User avatar
fo0k
Posts: 1433
Joined: Fri Oct 16, 2009 4:21 pm
Location: UK

Re: [Tool]Snip'n'Stitch v1

Post by fo0k »

Just tested with a 16384x16384 image and only took 10 seconds to spit out 4096 images..

Great tool.. great work :)
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: [Tool]Snip'n'Stitch v1

Post by Senshi »

Updated, see first post.

v2 - 13.Jan 13
  • Preview for snip, showing the resulting cut lines directly on top of the input image.
  • Automated check for new versions (yay). If an update exists, a popup will allow you to get a direct download link to the new 7z archive. No self-updater (yet?), sorry.
Pigauchiu
Posts: 31
Joined: Fri Mar 30, 2012 1:00 pm

Re: [Tool]Snip'n'Stitch v2

Post by Pigauchiu »

v2 not working. it simply failed to start. after doubling clicking on SnipnStitch_2.jar, javaw.exe appeared in my taskmgr for a few seconds only and then self terminated. anyone knows what's the problem?
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: [Tool]Snip'n'Stitch v2

Post by Senshi »

Should be started with java -jar, not javaw -jar. Probably your registry entry for jarfile is wrong. You can write your own batch file to start it or launch from the cmd directly:
java -jar SnipnStitch_v2.jar
User avatar
fo0k
Posts: 1433
Joined: Fri Oct 16, 2009 4:21 pm
Location: UK

Re: [Tool]Snip'n'Stitch v2

Post by fo0k »

for the first version of this I simply double click the jar file.. and it works..

v2 not liking that. should it be run differently?

could you post an example batch file.. if you think would help. Im not too clued up.

assuming this looks correct..?
cmd.png
cmd.png (1.67 KiB) Viewed 17837 times
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: [Tool]Snip'n'Stitch v2

Post by Senshi »

Your code should work. The problem seems to be that you did not install Java properly or at least the file command is not declared which is usually a registry issue (also fixable by reinstalling Java). So: Reinstall Java ;) .

java -jar SnipnStitch_2.jar

If you want a batch to start things up, use this

Code: Select all

start "" /B "javaw" -jar SnipnStitch_2.jar
Using java means you get the log&debug output in the console, using javaw means you don't get this (which can be cluttery). The "start /B" thingie means that the cmd used by the batch will close itself after launching the java app so no useless terminals float around.
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: [Tool]Snip'n'Stitch v3

Post by Senshi »

Upon retrying the program myself, I found a critical bug that causes a startup failure. I also noticed some other bugs that crippled the preview image (e.g. not updating when scrolling, resize of image always reset the image to 0-0 coordinates disregarding scrollbar positions).

First post updated with changelog, get the new version either there or via the self-updater notice.
User avatar
fo0k
Posts: 1433
Joined: Fri Oct 16, 2009 4:21 pm
Location: UK

Re: [Tool]Snip'n'Stitch v3

Post by fo0k »

thank you sir.

you appear to have an extra bracket in the naming scheme example above..? just whilst I'm being helpful..
any news on the stitch?
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: [Tool]Snip'n'Stitch v3

Post by Senshi »

Thanks for spotting that, fook, fixed it :) .

Stitch....didn't hear anyone calling a need for it, so I froze that feature. Especially as it would mean a whole lot of new work ;) . If demand exists, it might come someday, but don't expect any serious for the next 4 weeks, I'm in the process of moving (out of Germany, even if just barely...) and finally really ending my studies and all that entails quite a bit of work and stress.
Post Reply