Menu

LEX File Exchange
EA Support Files
SC4 Wikipedia
Network Addon Mod
Dependencies
Chat

Author Topic: Png to Fsh Conversion tool  (Read 23020 times)

0 Members and 1 Guest are viewing this topic.

Offline null45

  • Lex Certified
  • Forums Mayor
  • *
  • Posts: 221
  • Total likes: 27
  • Reputation: 18
  • CL:
    All formats lead to FSH
Png to Fsh Conversion tool
« 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.



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  :)
« Last Edit: October 16, 2009, 04:04:18 PM by null45 »

Offline sithlrd98

Re: Png to Fsh Conversion tool
« Reply #1 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

Offline null45

  • Lex Certified
  • Forums Mayor
  • *
  • Posts: 221
  • Total likes: 27
  • Reputation: 18
  • CL:
    All formats lead to FSH
Re: Png to Fsh Conversion tool
« Reply #2 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.





Jonathan's Fsh to Png tool also works on linux using Mono.  ;)
 
« Last Edit: April 25, 2009, 07:20:14 PM by null45 »

Offline Andreas

  • Administrator
  • Forums Legend
  • *
  • Posts: 4775
  • Total likes: 987
  • Reputation: 33
    • SimCityPlaza
  • CL: ()bobby() Transit Controller
Re: Png to Fsh Conversion tool
« Reply #3 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? :)
Andreas

Offline null45

  • Lex Certified
  • Forums Mayor
  • *
  • Posts: 221
  • Total likes: 27
  • Reputation: 18
  • CL:
    All formats lead to FSH
Re: Png to Fsh Conversion tool
« Reply #4 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:

Offline null45

  • Lex Certified
  • Forums Mayor
  • *
  • Posts: 221
  • Total likes: 27
  • Reputation: 18
  • CL:
    All formats lead to FSH
Re: Png to Fsh Conversion tool
« Reply #5 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:

Offline Pat

  • when life tosses you lemons, make lemonade!
  • 3RR Team
  • Forums Legend
  • *
  • Posts: 8812
  • Total likes: 6
  • Reputation: 45
  • SC4D Podcast, You Know You Wanna Hear IT!!!!
  • CL: ()pathfire() gettin' it right!
Re: Png to Fsh Conversion tool
« Reply #6 on: April 08, 2009, 09:40:43 PM »
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

Offline null45

  • Lex Certified
  • Forums Mayor
  • *
  • Posts: 221
  • Total likes: 27
  • Reputation: 18
  • CL:
    All formats lead to FSH
Re: Png to Fsh Conversion tool
« Reply #7 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.  :)

Offline Gwail

Re: Png to Fsh Conversion tool
« Reply #8 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?
My misc works thread:
GWL workshop

Offline null45

  • Lex Certified
  • Forums Mayor
  • *
  • Posts: 221
  • Total likes: 27
  • Reputation: 18
  • CL:
    All formats lead to FSH
Re: Png to Fsh Conversion tool
« Reply #9 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.

Offline Gwail

Re: Png to Fsh Conversion tool
« Reply #10 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.
My misc works thread:
GWL workshop

Offline null45

  • Lex Certified
  • Forums Mayor
  • *
  • Posts: 221
  • Total likes: 27
  • Reputation: 18
  • CL:
    All formats lead to FSH
Re: Png to Fsh Conversion tool
« Reply #11 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?
 
« Last Edit: April 29, 2009, 06:31:44 PM by null45 »

Offline cogeo

  • NAM Team
  • Forums Parliamentarian
  • *
  • Posts: 1160
  • Total likes: 38
  • Reputation: 18
  • CL:
    SC4 Station Master
Re: Png to Fsh Conversion tool
« Reply #12 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.

Offline Gwail

Re: Png to Fsh Conversion tool
« Reply #13 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:


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

Offline null45

  • Lex Certified
  • Forums Mayor
  • *
  • Posts: 221
  • Total likes: 27
  • Reputation: 18
  • CL:
    All formats lead to FSH
Re: Png to Fsh Conversion tool
« Reply #14 on: April 29, 2009, 06:27:03 PM »
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  ;)
« Last Edit: May 02, 2010, 11:27:19 PM by null45 »

Offline Gwail

Re: Png to Fsh Conversion tool
« Reply #15 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.
My misc works thread:
GWL workshop

Offline null45

  • Lex Certified
  • Forums Mayor
  • *
  • Posts: 221
  • Total likes: 27
  • Reputation: 18
  • CL:
    All formats lead to FSH
Re: Png to Fsh Conversion tool
« Reply #16 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. ;) 
« Last Edit: May 04, 2009, 09:39:27 PM by null45 »

Offline Gwail

Re: Png to Fsh Conversion tool
« Reply #17 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!
My misc works thread:
GWL workshop

Offline null45

  • Lex Certified
  • Forums Mayor
  • *
  • Posts: 221
  • Total likes: 27
  • Reputation: 18
  • CL:
    All formats lead to FSH
Re: Png to Fsh Conversion tool
« Reply #18 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.

Offline superhands

  • NAM Team
  • Forums Senator
  • *
  • Posts: 928
  • Total likes: 1
  • Reputation: 12
  • was bighead99
    • f u t u r e  p e r t h
  • CL: One Track Mind
Re: Png to Fsh Conversion tool
« Reply #19 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.


however i can not recreate this using my own textures.

any ideas?

dave