• Welcome to SC4 Devotion Forum Archives.

Png to Fsh Conversion tool

Started by null45, March 14, 2009, 07:23:31 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

null45

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.



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

The file version should be "1.4.0.0"

I hope someone finds this useful  :)

sithlrd98

Oh , yeah! It does work a lot easier than messing with FishMan! Thank you!  &apls(What else you got up your sleeve?)

Jayson

null45

#2
It also works on linux.
FiSHMan works on linux when using Mono 2.4 or Mono 2.0.1.





Jonathan's Fsh to Png tool also works on linux using Mono.  ;)

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? :)
Andreas

null45

Quote from: AndreasVery 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:

null45

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:

Pat

this I will have to check out Null and thank you!!!

Don't forget the SC4D Podcast is back and live on Saturdays @ 12 noon CST!! -- The Podcast soon to Return Here Linkie

null45

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.  :)

Gwail

Quote from: null45 on March 14, 2009, 07:23:31 PM
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?
My misc works thread:
GWL workshop

null45

QuoteIs 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.

Gwail

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.
My misc works thread:
GWL workshop

null45

#11
QuoteSo 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?

cogeo

Quote from: null45 on April 28, 2009, 02:29:01 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.

Gwail

Quote from: null45 on April 28, 2009, 02:29:01 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:


And my quick sample, obtained with method mentioned last time:


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:.
My misc works thread:
GWL workshop

null45

#14
It should be able to handle 512 x 512 textures.

 

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
File version should be 1.4.0.0

I hope it works  ;)

Gwail

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.
My misc works thread:
GWL workshop

null45

#16
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. ;) 

Gwail

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+.
************** 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!
My misc works thread:
GWL workshop

null45

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.

superhands

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.


however i can not recreate this using my own textures.

any ideas?

dave