Sim City 4 Devotion Forums

Sim City 4 Devotion Tools => Tools - General Discussion => null45's Tools => Topic started by: null45 on March 14, 2009, 09:23:31 PM

Title: Png to Fsh Conversion tool
Post by: null45 on March 14, 2009, 09:23:31 PM
This is  a tool that I wrote to convert Png files into Fsh files.
It should be simpler than FiSHMan when creating single image fsh files.
It supports creating both regular & compressed fsh files.

(http://img23.imageshack.us/img23/8369/37a53fsh.png)

The fastest way to create a fsh is to drag a png or bmp image onto the "Save fsh" or "compressed fsh" buttons.
It will automatically add the alpha channel if it is named using a filename like "filename_a.png".

One problem with this is that if it finds a alpha channel it will save it as DXT3 not DXT1, so if you just need a plain white alpha
the best way is to just have the bitmap & it will generate an alpha.

Or if your image has transparency you can use the "Alpha map from transparency" option to generate the alpha map based on the
images transparent pixels.
If the image needs a alpha map and does not have any transparency, the "Alpha map from transparency" will generate a plain white alpha.

It will also load /save the fsh files TGI, the Instance range can be overridden by placing text file named "instRange.txt" in the same folder as the program this is basically a renamed copy of Sc4 Tool's Range.txt. 

It can be set to open fsh and bmp / png files from the open with / right click menu.

It can also export the image's bitmap, the image's alpha or the image's bitmap combined with the the alpha map.
 
Download: Png to Fsh (http://www.mediafire.com/download.php?ynyzjywmjnk)

The file version should be "1.4.0.0"

I hope someone finds this useful  :)
Title: Re: Png to Fsh Conversion tool
Post by: sithlrd98 on March 14, 2009, 09:35:50 PM
Oh , yeah! It does work a lot easier than messing with FishMan! Thank you!  &apls(What else you got up your sleeve?)

Jayson
Title: Re: Png to Fsh Conversion tool
Post by: null45 on March 15, 2009, 06:14:36 PM
It also works on linux.
FiSHMan works on linux when using Mono 2.4 or Mono 2.0.1.



(http://img27.imageshack.us/img27/4465/jd789mnd.png)

Jonathan's Fsh to Png tool also works on linux using Mono.  ;)
 
Title: Re: Png to Fsh Conversion tool
Post by: Andreas on March 15, 2009, 06:38:50 PM
Very nice. I haven't tried it yet, but maybe Jonathan and you could join forces to create a program that works both ways with the same kind of simplicity? :)
Title: Re: Png to Fsh Conversion tool
Post by: null45 on March 15, 2009, 10:30:29 PM
Quote from: Andreas
Very nice. I haven't tried it yet, but maybe Jonathan and you could join forces to create a program that works both ways with the same kind of simplicity?

That is a interesting idea.

I also have a Png to Fsh converter that is like Jonathan's Fsh to BMP tool, meaning it has only buttons that can be used to drop files onto.
Although I think it is better to have a picture box to view the Bitmaps in a Fsh.  :thumbsup:
Title: Re: Png to Fsh Conversion tool
Post by: null45 on April 08, 2009, 09:38:05 PM
A small update, mainly better HD fsh support and the ability to automatically generate the alpha map
from the image transparency.

The "Alpha map from transparency" function requires the bitmap to be a 32 bit png image.

See first post.  :thumbsup:
Title: Re: Png to Fsh Conversion tool
Post by: Pat on April 08, 2009, 09:40:43 PM
this I will have to check out Null and thank you!!!
Title: Re: Png to Fsh Conversion tool
Post by: null45 on April 11, 2009, 08:32:40 PM
The ability to view the bitmap alpha blended &
the ability to export the images bitmap & alpha without blending has been added. (though exporting the bitmap without blending is
really only useful for the emergency lights)

A few bugs fixed.  :)
Title: Re: Png to Fsh Conversion tool
Post by: Gwail on April 22, 2009, 03:24:29 AM
It should be simpler than FiSHMan when creating single image fsh files.
Is it possible to make the same tool (or expand existing one) for multi-image fsh?
Title: Re: Png to Fsh Conversion tool
Post by: null45 on April 22, 2009, 04:25:08 PM
Quote
Is it possible to make the same tool (or expand existing one) for multi-image fsh?

Could you be more specific on what you would want to do?

It is already capable of viewing the images / extracting bitmaps in a multi-image fsh, it can also replace the bitmap, overwriting one of the existing bitmaps in the fsh.
Title: Re: Png to Fsh Conversion tool
Post by: Gwail on April 28, 2009, 01:31:48 AM
Sorry for my non precise question. I mean the analogical tool as Texture Tool within SC4 Tool - just for multi-image FSH (SC4 Tool only supports single image FSH).

So far, if you want to make multi-image base/overlay texture, you have to use SC4 Tool for first texture in ordinary way, next extract all five fsh files, add another textures with FiSHman and then import fsh files into dat using Reader. It's a bit time consuming for more textures, unless I don't know a software able to do it.
Title: Re: Png to Fsh Conversion tool
Post by: null45 on April 28, 2009, 04:29:01 PM
Quote
So far, if you want to make multi-image base/overlay texture, you have to use SC4 Tool for first texture in ordinary way, next extract all five fsh files, add another textures with FiSHman and then import fsh files into dat using Reader. It's a bit time consuming for more textures, unless I don't know a software able to do it.

By other textures do you mean 256 x 256 textures?
I have not seen multi image fsh files used in the game, are there any samples?
 
Title: Re: Png to Fsh Conversion tool
Post by: cogeo on April 28, 2009, 04:43:00 PM
By other textures do you mean 256 x 256 textures?
I have not seen multi image fsh files used in the game, are there any samples?

Sach a texture is the one used in dirty industrials as a base texture (0x25420000). The game selects the texture randomly.
Title: Re: Png to Fsh Conversion tool
Post by: Gwail on April 28, 2009, 09:44:42 PM
By other textures do you mean 256 x 256 textures?
I have not seen multi image fsh files used in the game, are there any samples?

Try to plop any of original Maxis park lots. Best result will be with plazas, of course, but the grass texture is multi-imaged, too. Here's sample - same lot (1x1 plaza) - couple of plops:
(http://img211.imageshack.us/img211/804/multi00.jpg)

And my quick sample, obtained with method mentioned last time:
(http://img207.imageshack.us/img207/4096/multi01.jpg)

It is very useful for all land covering lots. Of course, it would be great to be able handling both standard 128x128 and HD 256x256 textures :thumbsup:.
Title: Re: Png to Fsh Conversion tool
Post by: null45 on April 29, 2009, 06:27:03 PM
It should be able to handle 512 x 512 textures.

(http://img198.imageshack.us/img198/5993/multifsh459.png) 

The "Generate Mipmaps" function generates a scaled down copy of the selected image, for example a 256x256 bitmap
would be scaled to 64x64, 32x32, 16x16 and 8x8.

It will also load /save the fsh files TGI, the Instance range can be overridden by placing text file named "instRange.txt" in the same folder as the program this is basically a renamed copy of Sc4 Tool's Range.txt.

You can use the open with / right click menu to open a png / bmp file & it will be added to a new fsh.

Download: This tool has been replaced by the one in this thread (http://sc4devotion.com/forums/index.php?topic=10731.0)
File version should be 1.4.0.0

I hope it works  ;)
Title: Re: Png to Fsh Conversion tool
Post by: Gwail on May 04, 2009, 01:56:45 AM
You're damn pretty quick, null45!

Sorry for delaying, I'm having the hottest time IRL just now. I'll try the tool and give a feedback ASAP.
Title: Re: Png to Fsh Conversion tool
Post by: null45 on May 04, 2009, 09:33:41 PM
The base of the code, the part that displays the images in the fsh in a list had been previously implemented as a test project .
It was then just a matter of adding the remaining functions. ;) 
Title: Re: Png to Fsh Conversion tool
Post by: Gwail on May 13, 2009, 03:59:35 AM
All right, let's go with a feedback. First of all, I've got technical issues handling with this tool as follows (after attemping to add another texture):

A generic error occured in GDI+.
Code: [Select]
************** Exception Text **************
System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
   at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
   at System.Drawing.Image.Save(String filename, ImageFormat format)
   at Multifshview_test.Multifshfrm.RefreshBitmapList()
   at Multifshview_test.Multifshfrm.addbtn_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Multifshview
    Assembly Version: 1.3.0.0
    Win32 Version: 1.3.0.0
    CodeBase: file:///F:/sc%20work/__Tools/MultiFsh/Multifshview.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
FSHLib
    Assembly Version: 0.3.1.32075
    Win32 Version: 0.3.1.32075
    CodeBase: file:///F:/sc%20work/__Tools/MultiFsh/FSHLib.DLL
----------------------------------------

Clicking "continue" allows to work, but I'm not sure if everything is ok, probably not - choosing bitmap #2 or more gives another error box: Index was outside the bounds of the array.

Beside this, some of my advice (and wishes, too), how this multifsh tool should work. First of all, making base/overlay textures should handle 5 FSH files at once. I realise you probably know it, but for sure I'll explain. Every zoom bitmap is stored in different FSH file as TGI follows:
0xXXXXXXX0-4 (0 is the smallest, 4 is the biggest),
0xXXXXXXX5-9 (5 is the smallest, 9 is the biggest),
0xXXXXXXXA-E (A is the smallest, E is the biggest).

Now, generate mipmaps should add proper downscaled bitmap in proper FSH file, on the proper layer (slot 0-3 for multi-textures - I haven't tried if more textures work - I shall make some tests). That way it would be better to handle .dat instead of .fsh file. The tool should allow only to choose the texture using TGI with digit 0, 5, A.

I know it does change your tool much, null45. I don't expect you'll agree to make this, although it would be very appreciated -I'm going to use multitextures pretty intensively ;).

Anyway, thanks for the time you've spent!
Title: Re: Png to Fsh Conversion tool
Post by: null45 on May 13, 2009, 06:22:18 PM
That crash was a mistake I made while coding, I forgot to remove a line of code that saved all the bitmaps to a folder.

As to loading dat files that probably will not be implemented, the other functions automatically setting the TGI for the reader and loading a fsh file for each size for example could be implemented.
Title: Re: Png to Fsh Conversion tool
Post by: superhands on May 23, 2009, 06:19:38 AM
hi null.

 i noticed that some of the overlay lot textures in the maxis dat had no alphas. just black on the negative space of the texture. but displays as opac in game.
(http://i293.photobucket.com/albums/mm50/bighead99999/BLACKBNOALPHA.jpg)

however i can not recreate this using my own textures.

any ideas?

dave
Title: Re: Png to Fsh Conversion tool
Post by: null45 on May 23, 2009, 02:43:50 PM
The alpha on those textures is fully opaque, meaning it should not appear semi-transparent.

As far as I can tell that overlay texture is not semi-transparent, if it is I do not know how to recreate it.  :)

 
Title: Re: Png to Fsh Conversion tool
Post by: Chrisim on May 23, 2009, 04:34:24 PM
This will become a very useful tool.  :thumbsup:
Why did you remove the option "Alpha map from transparency"?
Title: Re: Png to Fsh Conversion tool
Post by: null45 on May 23, 2009, 05:07:13 PM
Quote from: Chrisim
Why did you remove the option "Alpha map from transparency"?

What makes you think I removed that function?

In my Png to Fsh tool for the "Alpha map from transparency" function to work the checkbox must be checked and the bitmap must be a 32 bit png.
In my Multi fsh tool the same function exists but it automatically decides if it can use it or not.   :) 
Title: Re: Png to Fsh Conversion tool
Post by: null45 on June 02, 2009, 08:52:31 PM
Both tools updated to be able to load / save the TGI data for The Reader, a few bugs fixed.  :thumbsup:
Title: Re: Png to Fsh Conversion tool
Post by: Gwail on October 16, 2009, 05:34:52 AM
Refresh :)!

Does anybody else experience FSH handling error under WinXP after latest MS patch pack? Today right before update I was able to open and edit FSH files using both MultiFSH and FiSHman, after installation and reboot it isn't possible any more:

(http://img136.imageshack.us/img136/5720/fsherror.png)

I've tried to use the fixed fshlib.dll, no result.
Title: Re: Png to Fsh Conversion tool
Post by: Tarkus on October 16, 2009, 02:20:24 PM
I'm getting some similar problems as well . . . I've become an avid user of the PngToFsh Batch program here (which has become indispensable to all my transit modding projects :thumbsup:), and started noticing problems with it a couple days ago that prevented me from saving to .dat.  I tested out this program, too, just a moment ago, and had similar issues with saving and loading.

-Alex
Title: Re: Png to Fsh Conversion tool
Post by: null45 on October 16, 2009, 04:06:32 PM
The Vista fix will now work on XP, all of my tools have been updated with the new version (The Fsh Thumbnail handler does not need to be updated because it will not install on XP).
Title: Re: Png to Fsh Conversion tool
Post by: Tarkus on October 16, 2009, 04:34:44 PM
Thanks for the quick fix, null!  I'm back in business! :)

-Alex
Title: Re: Png to Fsh Conversion tool
Post by: Gwail on October 20, 2009, 03:57:50 AM
Works fine, thanks, null!

A small feeback about last release - multi tool works well, now making multitextures will be much simplier. Haven't found any issues so far, except a bit odd handling with transparent 256x256 textures, using for automata. But it's rather a manner of learning the tool better.

I'm not sure if is it an issue, but if you load a 256x256 bitmap, set "regular fsh" option and generate mipmaps, you receive the mipmaps for regular, 128x128 texture (64x64, 32x32 and so on). If it isn't intentional, maybe there should be any warning (with question "are you sure [yes-no]") that the texture mismatches the chosen FSH type?
Title: Re: Png to Fsh Conversion tool
Post by: null45 on October 20, 2009, 07:55:36 PM
I'm not sure if is it an issue, but if you load a 256x256 bitmap, set "regular fsh" option and generate mipmaps, you receive the mipmaps for regular, 128x128 texture (64x64, 32x32 and so on). If it isn't intentional, maybe there should be any warning (with question "are you sure [yes-no]") that the texture mismatches the chosen FSH type?

What do you mean when you say "that the texture mismatches the chosen FSH type"?
Title: Re: Png to Fsh Conversion tool
Post by: SimFox on December 13, 2009, 03:45:03 PM
Hi!

I've run into this problem with your tool:

(http://s41.radikal.ru/i092/0912/e5/a53bbc478c10.png)

the same message pops up also when saving with DXT1 compression is selected.

OS is Windows 7 x64

Do you have any idea how this could be remedied?