Menu

LEX File Exchange
EA Support Files
SC4 Wikipedia
Network Addon Mod
Dependencies
Chat
Welcome, Guest. Please login or register.
Did you miss your activation email?

June 18, 2021, 10:08:54 PM

Login with username, password and session length

Author Topic: Simple FSH<>PNG Tools  (Read 29800 times)

0 Members and 1 Guest are viewing this topic.

Offline Jonathan

  • NAM Team
  • Forums Guru
  • *
  • Posts: 2609
  • Total likes: 6
  • Reputation: 25
  • CL: Einstein, Jr. &scl()
Re: Simple FSH to BMP tool
« Reply #20 on: March 05, 2009, 12:58:06 PM »
Cogeo, this tool is a FSH > BMP tool,
I didn't find any documentation, so it took quite a while of trial, error and google.

I have tried to make a BMP to FSH Tool but that seems much harder to code, I'll attach the source code, what is the best format, the VB project or just a text file file of the class?

EDIT: here's the basic FSH function

Code: [Select]
   Function LoadFSH(ByVal file)
        Dim Fsh As New FSHLib.FSHImage
        Dim stream As System.IO.Stream
        stream = IO.File.OpenRead(file)
        Fsh.Load(stream)
        Dim FSHBMP As FSHLib.BitmapItem
        FSHBMP = Fsh.Bitmaps.Item(0)
        Return FSHBMP
        r.Close()
    End Function

Then to get the bitmap and alpha's(respectively):
(NB: "My.Application.CommandLineArgs(0)" is the location of the FSH file you want to convert to bmp.)
Code: [Select]
LoadFSH(My.Application.CommandLineArgs(0)).Bitmap.Save(bitmapsaveloc)
LoadFSH(My.Application.CommandLineArgs(0)).Alpha.Save(alphasaveloc)

It seems there can be more than one bitmap in a FSH, but in SC4 this isn't used.

Jonathan


Offline cogeo

  • NAM Team
  • Forums Parliamentarian
  • *
  • Posts: 1160
  • Total likes: 38
  • Reputation: 18
  • CL:
    SC4 Station Master
Re: Simple FSH to BMP tool
« Reply #21 on: March 05, 2009, 01:27:12 PM »
Aaah, I see, this is a library with a VB Object.

Btw, there are multi-image FSH files in the simcity dats. If used as lot textures, the game selects one of the images randomly.

Offline dedgren

Re: Simple FSH to BMP tool
« Reply #22 on: March 05, 2009, 01:37:30 PM »
Well, that's something.  My converted file opens just fine in Paint.

And...

...checking, checking...

...when I save it as a PNG from Paint, it opens just fine in PSP.

Well, that works.  Kinda sorta.

But, great job!  I was pretty worried about Vista and FSH files.


David
D. Edgren

Please call me David...

Three Rivers Region- A collaborative development of the SC4 community
The 3RR Quick Finder [linkie]


I atenít dead.  ó  R.I.P. Granny Weatherwax

Skype: davidredgren

Offline Jonathan

  • NAM Team
  • Forums Guru
  • *
  • Posts: 2609
  • Total likes: 6
  • Reputation: 25
  • CL: Einstein, Jr. &scl()
Re: Simple FSH to BMP tool
« Reply #23 on: March 05, 2009, 03:55:34 PM »
I was thinking of trying to add a png button in, that has an alpha included but can't find out how to do it.
I have an idea about the PSP thing, but will try it out some other time.
Also I've made a bulk version, which is attached below

Needs the FSHLib.dll which you can get in Null 45's post or the download in the first post.

Thanks for all your feedback so far, please give more on both programs, what you like and what you'd like changed, and then I'll do my best to learn how to do that.


David, try renaming the .bmp to .png, because maybe PSP is expecting a bmp but actaully the prgram is not saving it in bmp format?

Jonathan

Offline null45

  • Lex Certified
  • Forums Mayor
  • *
  • Posts: 221
  • Total likes: 27
  • Reputation: 18
  • CL:
    All formats lead to FSH
Re: Simple FSH to BMP tool
« Reply #24 on: March 05, 2009, 04:37:23 PM »
Bitmap.Save(bitmapsaveloc,ImageFormat.Bmp) is the method used to tell it to save in bmp format.

Is the drag & drop file conversion working Warrior?  :thumbsup:



« Last Edit: March 05, 2009, 05:23:47 PM by null45 »

Offline Andreas

  • Administrator
  • Forums Legend
  • *
  • Posts: 4795
  • Total likes: 1024
  • Reputation: 33
    • SimCityPlaza
  • CL: ()bobby() Transit Controller
Re: Simple FSH to BMP tool
« Reply #25 on: March 05, 2009, 04:53:33 PM »
Well, personally, I prefer PNG over BMP at any time, as PNG supports transparency. Of course texture transparency is handled via alpha maps in the game, but when editing overlays, having the source file with transparency in the first place is very helpful, rather than the need of using the alpha map in the graphics program as well for creating masks.
« Last Edit: March 05, 2009, 05:04:18 PM by Andreas »
Andreas

Offline sithlrd98

Re: Simple FSH to BMP tool
« Reply #26 on: March 05, 2009, 05:03:49 PM »
I was going to ask for a .png as well , but since this is an early attempt , I didn't want to push my luck :D

Also , I am using the FSHLib.dll that came with your program and still get the same errors: but if I change to .png , it opens in both PS and CS2.

Jayson

Offline wes.janson

  • Forums Governor
  • *
  • Posts: 396
  • Total likes: 1
  • Reputation: 2
  • Orange you glad I didn't say banana?
Re: Simple FSH to BMP tool
« Reply #27 on: March 05, 2009, 05:04:24 PM »
I agree with Andreas. I don't even use BMPs for my textures anymore. PNGs for the actual in game textures and psp for developing as it doesn't merge the layers in PSPXI


Henrik Sedin: 82gp 29g 83a 112p - 2009/2010 Art Ross/Hart Trophy winner!

Offline null45

  • Lex Certified
  • Forums Mayor
  • *
  • Posts: 221
  • Total likes: 27
  • Reputation: 18
  • CL:
    All formats lead to FSH
Re: Simple FSH to BMP tool
« Reply #28 on: March 05, 2009, 05:38:28 PM »
Quote
Also , I am using the FSHLib.dll that came with your program and still get the same errors: but if I change to .png , it opens in both PS and CS2.

What do you mean by getting errors?

If you meat that PSP is not able to load the saved bmp, that means it probably was not saved correctly or is invalid.

Or it is valid and PSP just doesn't like the bmp file.   ::)

If that is the case FSHLib.dll has nothing to do with the errors.

I agree that Png is better than Bmp, the demo I wrote saves as Png.
« Last Edit: March 05, 2009, 05:42:37 PM by null45 »

Offline sithlrd98

Re: Simple FSH to BMP tool
« Reply #29 on: March 05, 2009, 05:52:12 PM »
Sorry , the errors were posted on previous page. I only added the part about the .dll because I wasn't sure who Jonathan was directing in his prior post. But, like I said , if I change the newly created .bmp to a .png , both photo editors are able to read it.

Jayson

Offline null45

  • Lex Certified
  • Forums Mayor
  • *
  • Posts: 221
  • Total likes: 27
  • Reputation: 18
  • CL:
    All formats lead to FSH
Re: Simple FSH to BMP tool
« Reply #30 on: March 05, 2009, 06:16:52 PM »
Quote
David, try renaming the .bmp to .png, because maybe PSP is expecting a bmp but actaully the prgram is not saving it in bmp format?

That is correct the files are being saved as a png with a .bmp extension.

The code
Code: [Select]
LoadFSH(My.Application.CommandLineArgs(0)).Bitmap.Save(bitmapsaveloc)
should be
Code: [Select]
LoadFSH(My.Application.CommandLineArgs(0)).Bitmap.Save(bitmapsaveloc,ImageFormat.Bmp)
or you could change the extention to png in the code that you set the file extension in. 

Offline Jonathan

  • NAM Team
  • Forums Guru
  • *
  • Posts: 2609
  • Total likes: 6
  • Reputation: 25
  • CL: Einstein, Jr. &scl()
Re: Simple FSH to BMP tool
« Reply #31 on: March 06, 2009, 01:21:25 AM »
Thanks Null,
I have changed the code in both programs, so now it saves it as png format and with png extension, but there is still no option to have the alpha and bmp in one png file, I need to find out how to do that :)

And I haven't added the drag and drop yet, but I will later today/tommorrow


Jonathan

Offline dedgren

Re: Simple FSH to BMP tool
« Reply #32 on: March 06, 2009, 12:18:30 PM »
Hi, null45 and Jonathan-

Would it be possible (and not too much trouble) to make a parallel tool that goes in the other direction?  I would like an easy way to turn PNG files into FSH files, and in particular 256x256 pixel PNG files into 256x256 pixel FSH files.  The SC4Tool is limited to processing 128x128 pixel files.

Thanks for this great addition to the MODding toolbox.


David
D. Edgren

Please call me David...

Three Rivers Region- A collaborative development of the SC4 community
The 3RR Quick Finder [linkie]


I atenít dead.  ó  R.I.P. Granny Weatherwax

Skype: davidredgren

Offline Jonathan

  • NAM Team
  • Forums Guru
  • *
  • Posts: 2609
  • Total likes: 6
  • Reputation: 25
  • CL: Einstein, Jr. &scl()
Re: Simple FSH to BMP tool 6.1.0.0
« Reply #33 on: March 06, 2009, 01:50:12 PM »
Well it actually isn't converting the FSH to PNG, more like extracting the PNG from the FSH, and putting a PNG into a FSH seems harder, as I think you might have to 'build' the FSH(FSH is not a standard image(or whatever it is) format, I've looked at it and it isn't as simple as FSH to PNG.

Null45, you can probably help here?

EDIT: Update of ClickFSHToPNG to 6.1.0.0, now there is drag and drop functionality added. You can open the program directly, or just open it from a FSH file and drag any FSH file on it. Also if you open the program directly you can make it the topmost (it stays on top of other windows) so extracting lots of FSH is easier.

Jonathan

Offline null45

  • Lex Certified
  • Forums Mayor
  • *
  • Posts: 221
  • Total likes: 27
  • Reputation: 18
  • CL:
    All formats lead to FSH
Re: Simple FSH to BMP tool
« Reply #34 on: March 06, 2009, 03:39:12 PM »
Do you mean a tool that you drag a fsh file onto and then drag a bitmap to replace the existing bitmap in the fsh?

As to creating a completely new fsh, updating the bitmap / alpha & saving under a different file name would work.   

Edit:

 

A little demo. ;)
« Last Edit: March 07, 2009, 02:28:28 PM by null45 »

Offline Jonathan

  • NAM Team
  • Forums Guru
  • *
  • Posts: 2609
  • Total likes: 6
  • Reputation: 25
  • CL: Einstein, Jr. &scl()
Re: Simple FSH to BMP tool
« Reply #35 on: March 22, 2009, 11:15:28 AM »
Here's a new version, a lot of the changes are not (well shouldn't be) noticeable, it has just been to compact the code and remove duplicate sections.

But when opening the program from a FSH file (not drag and drop only), if you hover over any of the three buttons you'll get a preview of the image.
And you can turn the messages that pop up after you've finished on or off.

Jonathan

Offline Jonathan

  • NAM Team
  • Forums Guru
  • *
  • Posts: 2609
  • Total likes: 6
  • Reputation: 25
  • CL: Einstein, Jr. &scl()
Re: FSH2PNG MkII
« Reply #36 on: April 17, 2009, 03:40:41 AM »
Thanks to null45 who gave me a dll he made to make blended pngs, now I've made another tool that has no buttons, just open the file(s) with the program and it will convert them into blended pngs (so alpha and bitmap in one file)

You can also select multiple files and it will convert all of them.
And you must have version 0.3.1.31964 of the FSHLib.dll(included in the zip)

Jonathan


Offline SimGoober

Re: Simple FSH<>PNG Tools
« Reply #37 on: May 01, 2009, 04:46:45 PM »
Very cool tool!  Just what I needed for a quick project... new overlay textures based on previous ones.
When life just blows ... Fukitol!

Offline puresim

Re: Simple FSH<>PNG Tools
« Reply #38 on: January 13, 2010, 06:06:50 PM »
Hi guys. I'm running Windows XP SP3 but am having trouble getting any FSH to PNG programs to work. Even FISHMAN with the 0.3.1.32186 version of FSHLib.dll gives me errors.

I double click on the FSH2PNG MkII.exe file and it just shows me this:


I've downloaded it twice but still get the same window. Could someone explain how this works?
« Last Edit: January 13, 2010, 06:10:14 PM by puresim »

Offline null45

  • Lex Certified
  • Forums Mayor
  • *
  • Posts: 221
  • Total likes: 27
  • Reputation: 18
  • CL:
    All formats lead to FSH
Re: Simple FSH<>PNG Tools
« Reply #39 on: January 13, 2010, 11:23:00 PM »
With FSH2PNG MkII you have to drag and drop the fsh to be converted onto the program then it will convert it, the program would display that message box even if it was not given any files to convert.



FSH2PNG MkII will also crash with this dialog the fsh is invalid.