• Welcome to SC4 Devotion Forum Archives.

Simple FSH<>PNG Tools

Started by Jonathan, March 02, 2009, 12:11:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jonathan

#20
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


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

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


cogeo

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.

dedgren

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

Jonathan

#23
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

null45

#24
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:




Andreas

#25
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.
Andreas

sithlrd98

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

wes.janson

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!

null45

#28
QuoteAlso , 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.

sithlrd98

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

null45

QuoteDavid, 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 LoadFSH(My.Application.CommandLineArgs(0)).Bitmap.Save(bitmapsaveloc)

should be
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. 

Jonathan

#31
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

dedgren

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

Jonathan

#33
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

null45

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

Jonathan

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

Jonathan

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


SimGoober

Very cool tool!  Just what I needed for a quick project... new overlay textures based on previous ones.
When life just blows ... Fukitol!

puresim

#38
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?

null45

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.