Project Perfect Mod Forums
:: Home :: Get Hosted :: PPM FAQ :: Forum FAQ :: Privacy Policy :: Search :: Memberlist :: Usergroups :: Register :: Profile :: Log in to check your private messages :: Log in ::


The time now is Thu Mar 28, 2024 12:33 pm
All times are UTC + 0
BatchTMPConverter
Moderators: Community Tools Developpers
Post new topic   Reply to topic Page 1 of 1 [16 Posts] Mark the topic unread ::  View previous topic :: View next topic
Author Message
Starkku
Cyborg Commando


Joined: 28 Dec 2007
Location: Finland

PostPosted: Thu May 26, 2016 3:34 pm    Post subject:  BatchTMPConverter
Subject description: Command-line tool for converting TMP's.
Reply with quote  Mark this post and the followings unread

BatchTMPConverter is a command-line tool for replacing tile image data on Command & Conquer Tiberian Sun / Red Alert 2 terrain template (tmp) files. It allows for fast and quick conversion of PNG image files into already existing terrain templates, or vice-versa, exporting PNG images from existing terrain template files.

It works by looking for tmp files from input/files directories filtered by file extensions, and looking for a PNG image file matching the filename of the template (sans extension, of course). Only 32-, 24- and 8-bit images are supported as of current, with 8-bit images retaining their own palette information. Image dimensions have to match the full size of the template for the tool to attempt conversion. Image output mode (-o) does the reverse and exports 24-bit PNG images from the terrain template files, overwriting files with same filename.

DOWNLOAD (v.3.0.0): BatchTMPConverter.zip

System Requirements: Microsoft .NET Framework 4.0

Command-Line Arguments:
Code:

-h  | Show help.
-i= | A comma-separated list of input tmp file(s) and/or directory/directories.
-p= | Palette file to use for conversion.
-o  | Output template data as images instead of converting images to templates.
-e= | Comma-separated list of file extensions (including the .) to use instead of built-in defaults.
-r  | Alter tile radar colors based on new image & palette data.
-m= | Multiplier to radar color RGB values, if they are altered.
-x  | Allow overwriting background color pixels on existing extra images.
-b  | Disable backing up the edited files with same name using file extension .old.
-l  | Write log info to file as well as console.

Example: -i="C:\MyFiles,C:\MyFiles\MoreFiles\example.tem" -p="C:\MyFiles\isotem.pal" -e=".tem" -r -m="1.0"


Special Thanks:
To Olaf van der Spek for his documentation on TS/RA2 TMP file format.


Changelog:

Version 3.0.0
• Improved palette color matching, should come with slightly more accuracy under certain conditions and much faster runtime in exchange for somewhat increased memory consumption.
• Extra image data overlapping regular tile data is now clipped accordingly.
• Command-line argument -x can now be used to enable overwriting background color pixels in extra image data.
• Command-line argument -l can now be used to enable logging to file.

Version 2.0.0
• Added image export from template mode which can be enabled by using command line parameter -o.
• Now requires .NET Framework 4.0 instead of 2.0.

Version 1.0.1
• Silhouette of existing extra images is now respected and no pixels will be drawn on background color.
• Tool will now correctly draw background color over existing tile image data (except extra images) where needed.

_________________

Last edited by Starkku on Sat Jul 04, 2020 7:01 pm; edited 11 times in total

Back to top
View user's profile Send private message Visit poster's website ModDB Profile ID Twitter Channel URL
E1 Elite
General


Joined: 28 May 2013

PostPosted: Thu May 26, 2016 5:30 pm    Post subject: Reply with quote  Mark this post and the followings unread

XCC TMP Editor clips the extra image and fills with 0. This converter does not.



TmpConv.jpg
 Description:
Original - Full import in TMP Editor - TMP Converter
 Filesize:  43.84 KB
 Viewed:  8961 Time(s)

TmpConv.jpg



Back to top
View user's profile Send private message
Starkku
Cyborg Commando


Joined: 28 Dec 2007
Location: Finland

PostPosted: Thu May 26, 2016 5:39 pm    Post subject: Reply with quote  Mark this post and the followings unread

If you can show me that this has some effect on the display of tiles in the game, I will attempt to change it to work like XCC's but otherwise I will not bother.

_________________

Back to top
View user's profile Send private message Visit poster's website ModDB Profile ID Twitter Channel URL
E1 Elite
General


Joined: 28 May 2013

PostPosted: Thu May 26, 2016 5:44 pm    Post subject: Reply with quote  Mark this post and the followings unread

I don't think it will have any impact in-game except may be rendering some non-transparent pixels twice. But
I just checked it with just this one tile only and that too not in-game. Just saw the difference, so reported it.

Back to top
View user's profile Send private message
Starkku
Cyborg Commando


Joined: 28 Dec 2007
Location: Finland

PostPosted: Thu May 26, 2016 5:55 pm    Post subject: Reply with quote  Mark this post and the followings unread

Well thanks for the report in any case. I will see what I can do about it.

_________________

Back to top
View user's profile Send private message Visit poster's website ModDB Profile ID Twitter Channel URL
Lin Kuei Ominae
Seth


Joined: 16 Aug 2006
Location: Germany

PostPosted: Fri May 27, 2016 7:14 am    Post subject: Reply with quote  Mark this post and the followings unread

nice tool Starkku.

The doubled image on the extra graphics could cause trouble when rendering stuff that stands on this tile, causing the image in the high render layer extra graphic to be shown in front of the object.

_________________
SHP Artist of Twisted Insurrection:  Nod buildings

Public SHPs
X-Mech Calendar (28 Mechs for GDI and Nod)
5 GDI, 5 Nod, 1 Mutant, 1 Scrin unit, 1 GDI building

Tools
Image Shaper______TMP Shop______C&C Executable Modifier

Back to top
View user's profile Send private message
Mig Eater
Defense Minister


Joined: 13 Nov 2003
Location: Eindhoven

PostPosted: Fri May 27, 2016 10:30 am    Post subject: Reply with quote  Mark this post and the followings unread

When using the "paste complete" option in TMP Editor it will only apply the new image to pre-existing, non 0 colour pixels. If you use "paste extra image" then it will copy the whole image like in Starkku's program.

As LKO said it can cause problems & would need to be manually clipped or the Z-data lowered. However the majority of tiles using extra images aren't accessible to units, so the overlapping would be minimal.

It's a nice tool but for my workflow it would take just as long to save each tile as a PNG as it would to just copy it into TMP Editor. If you are just recolouring the original tiles tho I can see this as being a quick & easy way to do it.

_________________



Back to top
View user's profile Send private message Visit poster's website ModDB Profile ID YouTube User URL Facebook Profile URL Twitter Channel URL
E1 Elite
General


Joined: 28 May 2013

PostPosted: Fri May 27, 2016 6:39 pm    Post subject: Reply with quote  Mark this post and the followings unread

Exe has been updated but there is no update post, so assuming it is still WIP:
- If the new image is smaller than in the template, it retains the old surplus portions.
- Problem with RA2 cliff08.tem, the resulting tem file had distorted image even with its own exported
image. Tried few other tiles, they were fine.

Back to top
View user's profile Send private message
Starkku
Cyborg Commando


Joined: 28 Dec 2007
Location: Finland

PostPosted: Fri May 27, 2016 7:37 pm    Post subject: Reply with quote  Mark this post and the followings unread

I did issue an update earlier but it was faulty and quickly withdrawn. Here's a new one.

Version 1.0.1
* Silhouette of existing extra images is now respected and no pixels will be drawn on background color.
* Tool will now correctly draw background color over existing tile image data (except extra images) where needed.

I am unsure on cause of the distortion issue but it seems it is related to the input image, possibly only happening on 8-bit bitmaps. I will investigate.

_________________

Back to top
View user's profile Send private message Visit poster's website ModDB Profile ID Twitter Channel URL
E1 Elite
General


Joined: 28 May 2013

PostPosted: Sat May 28, 2016 2:55 pm    Post subject: Reply with quote  Mark this post and the followings unread

If there is support for larger image than the template image like in the yesterday's version, users will
have the ability to replace with a similar image. What XCC does with full import seems restrictive.

Back to top
View user's profile Send private message
Starkku
Cyborg Commando


Joined: 28 Dec 2007
Location: Finland

PostPosted: Sun Dec 08, 2019 12:51 pm    Post subject: Reply with quote  Mark this post and the followings unread

First post has been updated with download for the newest version which has a command line option for exporting 24-bit PNG images from the tmp files, basically reverse of what the tool usually does, plus some internal code tweaks.

_________________

Back to top
View user's profile Send private message Visit poster's website ModDB Profile ID Twitter Channel URL
Holland
Grenadier


Joined: 31 May 2017

PostPosted: Thu Mar 12, 2020 4:07 pm    Post subject: Reply with quote  Mark this post and the followings unread

Thank you for this too starkku.

I'm only not able to convert the PNG's back to tmp, how do u use the commands to do that?

Back to top
View user's profile Send private message
Starkku
Cyborg Commando


Joined: 28 Dec 2007
Location: Finland

PostPosted: Sat Jul 04, 2020 7:12 pm    Post subject: Reply with quote  Mark this post and the followings unread

Updated first post with a new version. Fixes the extra image clipping issue brought up a long time ago, adds an option to allow overwriting background color pixels on existing extra images, improved logging and probably most importantly changed how the palette color matching works which should provide a significant performance boost and more accurate color matching, albeit not noticeable most of the time.

_________________

Back to top
View user's profile Send private message Visit poster's website ModDB Profile ID Twitter Channel URL
Holland
Grenadier


Joined: 31 May 2017

PostPosted: Fri Apr 02, 2021 1:43 pm    Post subject: Reply with quote  Mark this post and the followings unread

I need some help with this tool, its not outputting the files
I have a folder full of PNG files, and i want them to be converted to TEM.

what does my command need?

batchtmpconverter.exe -i="C:\test\redketchup\" -p="C:\Games\CnCNet\isotem.pal" -e=".tem"

the png files are in the folder redketchup. i tried doing just 1 file, but no luck. tried many other changes, but its just not doing anything
Thanks for support  Smile

Back to top
View user's profile Send private message
E1 Elite
General


Joined: 28 May 2013

PostPosted: Fri Apr 02, 2021 2:38 pm    Post subject: Reply with quote  Mark this post and the followings unread

You need .tem files in the input folder with same filenames as the .PNG file in which the image will be inserted.

Back to top
View user's profile Send private message
Holland
Grenadier


Joined: 31 May 2017

PostPosted: Sat Apr 03, 2021 7:04 pm    Post subject: Reply with quote  Mark this post and the followings unread

Thnx elite. So i copied 400 random tem files for it to copy in, and after i finally got all the names right, the converter says the template sizes are wrong. (It did  do the ones with the right size tho.) So i have to make each file individual the right size first, sigh.
Or can it do this for me?
Is there a better way?

Edit: so i found a pretty fast way where i just opened each file and press 'insert' as many as needed and quickly save, so it has thr right size. Its still pretty fast.
2nd edit: oh i completely forgot about the tmp data lol, god im so dumb sometimes..

Alright well i tried, still gonna have to do each one individually after all lol

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [16 Posts] Mark the topic unread ::  View previous topic :: View next topic
 
Share on TwitterShare on FacebookShare on Google+Share on DiggShare on RedditShare on PInterestShare on Del.icio.usShare on Stumble Upon
Quick Reply
Username:


If you are visually impaired or cannot otherwise answer the challenges below please contact the Administrator for help.


Write only two of the following words separated by a sharp: Brotherhood, unity, peace! 

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © phpBB Group

[ Time: 0.1665s ][ Queries: 14 (0.0102s) ][ Debug on ]