I don't know if it's useful to anyone else, but I made it because other FSH Tools took to long, when I just quickly wanted to Convert FSH to BMP,
Just open the FSH with the Tool you get 3 buttons Bitmap Only, Bitmap and Alpha and Alpha Only, click what you want and the BMP appears almost immediately in the same location as the FSH file with the same name.
If anyone's interested post and then download the program in the attachment(includes Vista FSHLib.dll(should work on non Vista) :)
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fi200.photobucket.com%2Falbums%2Faa230%2FwarriorST%2FF2B.jpg&hash=8bef51216acb74d8a18e6ec8a25d14997c3ccef2)
Jonathan
Ohh a clever sounding little tool &apls
I'd be interested ::)
:satisfied:
TTC
Very nice, I would be interested too :thumbsup:
Cool. How does that work? Do you simply have to drag the FSH file onto the program window to open it, or do you have to select the file via a menu/dialogue? What about making those buttons a "hotspot" where you can drag the FSH onto, and it will be converted immediately?
I'll just attach to the post :)
btw, it includes the Vista FSHLib.dll, but I'm not 100% sure if it works on XP.
You have to open the the FSH with the program, so like either set it as the default program or right click, open with, FSH To BMP.
But you can't open the program directly and then open the FSH File.
Hotspots is an idea, I'll try making that but I think it will be beyond my programming knowledge :)
Jonathan
Thx Jonathan :thumbsup:
Quote from: Warrior on March 02, 2009, 12:53:38 PM
Hotspots is an idea, I'll try making that but I think it will be beyond my programming knowledge :)
Well, any programming knowledge is beyond me, so I have no idea how complicated that could be. All I know is that such programs do exist (i. e. for converting audio files), and for converting FSH files, it seem to be a nice trick. Assigning the FSH files to your program and opening them via double-click is pretty much as fast as well, though, so there's no need to dig any further. :)
Nice to see more and more programmers are in :)
good job :thumbsup:
:thumbsup: Great job Jonathan! Works as advertised (in Vista at least)! I am amazed constantly amazed by all the things that get produced for this game!
Jayson
Works on WinXP.
It should work on Win98 or newer :P
The vista friendly version should now have its own version number, to tell it apart from the non vista friendly versions.
The new FSHLib vista version: http://sc4devotion.com/forums/index.php?topic=5142.msg221467#msg221467 (http://sc4devotion.com/forums/index.php?topic=5142.msg221467#msg221467)
Any chance the vista friendly version can be uploaded to the LEX?
awesome that your programming Jon :)
any chance of the code? :D
Joe
Joe, We'll its the first thing I made I actually find useful ;)
Yep I could it's quite short (and probably not written in the best way), and its VB :)
Jonathan
Buttons that are "hotspot" meaning you can drag & drop files onto them are fairly easy to make when using the AllowDrop file property in the Visual Studio designer. ;)
In an demo I made the only purpose of the buttons was to drop fsh files to convert onto. :thumbsup:
I got the dropping to work, but didn't know how to get the DropData into a Stream, and couldn't find anything about it anywhere, so I kind of gave up :)
Jonathan
nice work jon. ;D
if it helps the code that i used for dropping is:
private void button2_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files)
{
FileInfo fi = new FileInfo(file);
if (fi.Exists)
{
if (fi.Extension.Equals(".fsh"))
{
FSHImage fsh = new FSHImage();
BitmapItem bi = new BitmapItem();
FileStream fstream = new FileStream(fi.FullName, FileMode.Open);
string path = Path.GetDirectoryName(Application.ExecutablePath);
fsh.Load(fstream);
bi = (BitmapItem)fsh.Bitmaps[0];
bi.Bitmap.Save(Path.Combine(path, Path.GetFileNameWithoutExtension(fi.FullName) + ".png"), ImageFormat.Png);
bi.Alpha.Save(Path.Combine(path, Path.GetFileNameWithoutExtension(fi.FullName) + "_a.png"), ImageFormat.Png);
}
}
}
}
Folks, I'm getting a "This is not a valid BMP/DIB/RLE file." message in PSP when I try to open the files that are output. Everything else appears to work as described. I run 64-bit Vista.
David
I tried it in paint and GIMP and paint and it works, could you try it in one of them as well?
Jonathan
That is strange,I get the same error in PSP8,Photoshop CS2 gives "could not complete your request because the file-format module cannot parse the file".
I also am on Vista 64 , the Windows photo gallery does open the file though.
Jayson
I could make a new FSH->BMP tool in the weekend. It should have a batch FSH->BMP function too.
Warior, do you have any documentation of this dll (functions, arguments, description etc), and an import library? How did you know what is available in there?
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
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.
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
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
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:
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.
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
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
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.
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
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.
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
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
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
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:
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fimg8.imageshack.us%2Fimg8%2F2568%2Fh257z5.png&hash=21e1d7f9bcb2729b7f32cd67eff90f2f3afbf876)
A little demo. ;)
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
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
Very cool tool! Just what I needed for a quick project... new overlay textures based on previous ones.
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:
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fi173.photobucket.com%2Falbums%2Fw73%2Fpurepics%2FGHRRRRRRRRRRRRRR.jpg&hash=53c2bd266453335037c34c5ef79929d3a0b32f3a)
I've downloaded it twice but still get the same window. Could someone explain how this works?
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.
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fimg63.imageshack.us%2Fimg63%2F5491%2Fcrasho.png&hash=0d35c110ca72f5da82dac55ed47ef0c2fae4491b)
FSH2PNG MkII will also crash with this dialog the fsh is invalid.
Sorry for the delay. I do get that error dialog when I drop the fsh files.
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fi173.photobucket.com%2Falbums%2Fw73%2Fpurepics%2FSC4%2Ferror.jpg&hash=5f3bcfee69617836e6df624d1e9b2d8bf620c62c)
Seems like Reader isn't saving the files properly. Thanks null45, I'll try to work it out.
I'm sorry I have no idea why you are getting that error, could you attach the FSH file that produced the error?
Anyway I have made a new program which does as the title of this thread says FSH<>PNG you just open a file, whether it is a PNG of FSH. And you can copy it to the clipboard as a file (.png) or a image which you can paste into a program such as paint. Also you can bulk convert and you can edit a FSH (and if you really want to a PNG) in an external app such as Paint/Photoshop and save it as a FSH without having to convert it yourself.
And it will eventually have the same drag and drop feature as the previous app did:
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fi200.photobucket.com%2Falbums%2Faa230%2FwarriorST%2FnewFSHtool.jpg&hash=35b405bf03eb6198644f5954441d06d4d16aadcb)
Jonathan
The program would not crash if the code is encased in a try catch block eg.
<STAThread()> _
Public Shared Sub Main(ByVal args As String())
Try
' is there an image to convert
If args.Length > 0 Then
For Each a As String In args
Dim fi As New FileInfo(a)
Using fs As New FileStream(fi.FullName, FileMode.Open, FileAccess.Read)
Dim fsh As New FSHImage(fs)
Dim bi As BitmapItem = DirectCast(fsh.Bitmaps(0), BitmapItem)
Dim bl As New BlendBitmap()
Dim bmp As Bitmap = bl.BlendBmp(bi)
bmp.Save(Path.Combine(fi.DirectoryName, String.Concat(Path.GetFileNameWithoutExtension(fi.Name), ".png")))
End Using
Next
Else
Interaction.MsgBox("An image must be dragged onto the program to convert it", MsgBoxStyle.Information, "No image to convert")
End If
Catch ex As Exception
Interaction.MsgBox(ex.Message, MsgBoxStyle.Critical, "Error converting file")
End Try
End Sub
Hopefully that helps. :thumbsup:
Quote from: Jonathan on January 16, 2010, 04:11:43 PM
I'm sorry I have no idea why you are getting that error, could you attach the FSH file that produced the error?
It's not just this program that can't open the fsh files (i.e. nothing to do with your scripting!). Here (edit: removed link) are 2 fsh files I've just saved from texture viewer in Reader, both produce the error message when dragged onto FSH2PNG.
If I'm honest I gave up trying to get it to work and just started working on another building model. My computer is telling me I have .NET framework 1, 2, 3 and 3.5 - Not sure if that is normal.
btw Jonathan I'm very interested in your new program, would be great if that worked for me.
Both of those fsh files are valid and work fine for me.
What error does FiSHMan give?
In desperation I reinstalled Fishman and the FSHLib.dll file last night and finally got it to open my fsh files. I still get the same error from FSH2PNG though.
FiSHman was giving me an invalid file error before, but the new installation seems fine. Thanks for your help guys :)
are you using the same FSHLib.dll in both programs, try copying the one from FiSHMan folder to the FSH2PNG folder.
They work fine with the FSH2PNG on my PC.
This is embarassing but that just worked &ops I was 99.9% sure that was the latest FSHLib.dll file!
Thanks all!
The whole point of this tool was to make converting FSH to PNG and back to FSH again just to edit it redundant. But I got a little carried away
So this program does the same as FSH2PNG, as well as have a proper interface.
To convert FSH(s) to PNG in the same style as FSH2PNG, all you have to do is drop the FSHs onto the program icon, and hold the Control Key down as you do so. Or set the program as the default for FSH and hold Control as you open them.
Another option is to use the FSHPNGConverter - Quick Convert icon. This is just a short cut to FSHPNGConverter with the command line arguement /c.
If you don't hold Control down then it opens the FSHPNGConverter and puts the FSHs you dropped on the icon or opened into the list in the left.
To edit a FSH without converting it back and forth (the program does this automatically for you) open it in FSHPNGConverter and the select it in the list, then click Edit in App button. This lets you select the program you want to open it in (say photoshop). After that the FSHPNGConverter dissapears and the program will load with the FSH open in it. Then When you are done click save and the close (please remember to save :)). The FSHPNGConverter will reappear with the edited FSH in it. You can then click Save to save it a FSH. (So you must save it in the editing program and FSHPNGConverter )
Saving the FSH:
There are different Types of FSH, uncompressed/compressed and alpha/no-alpha and the combinations of the two. in FSHPNGConverter you just select Compressed or Uncompressed from the combobox at the bottom right.
It will see if there is an alpha or not.
The default is compressed.
You can also copy the FSH as a PNG file (that you can paste into explorer) onto the clipboard
Or copy the FSH as an image (that you can paste into MS paint etc) onto the clipboard.
You can also drag and drop FSH/PNGs onto the listview. And the program can have PNGs dragged onto it's icon/opened with it.
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fi200.photobucket.com%2Falbums%2Faa230%2FwarriorST%2FFSHPNGConverter.jpg&hash=66f65db4684214c820b301986c744ce6822f222c)
Jonathan
That's a lot of useful new features! :thumbsup: Looks really simple to use from the screenshot - Where can we download it from?
I run into a last minute problem, that I need to fix but don't have the time until this weekend.
Here is the FSHConverter Tool, finally got round to fixing the issue.
Quote from: Jonathan on February 15, 2010, 10:09:59 AM
The whole point of this tool was to make converting FSH to PNG and back to FSH again just to edit it redundant. But I got a little carried away
So this program does the same as FSH2PNG, as well as have a proper interface.
To convert FSH(s) to PNG in the same style as FSH2PNG, all you have to do is drop the FSHs onto the program icon, and hold the Control Key down as you do so. Or set the program as the default for FSH and hold Control as you open them.
Another option is to use the FSHPNGConverter - Quick Convert icon. This is just a short cut to FSHPNGConverter with the command line arguement /c.
If you don't hold Control down then it opens the FSHPNGConverter and puts the FSHs you dropped on the icon or opened into the list in the left.
To edit a FSH without converting it back and forth (the program does this automatically for you) open it in FSHPNGConverter and the select it in the list, then click Edit in App button. This lets you select the program you want to open it in (say photoshop). After that the FSHPNGConverter dissapears and the program will load with the FSH open in it. Then When you are done click save and the close (please remember to save :)). The FSHPNGConverter will reappear with the edited FSH in it. You can then click Save to save it a FSH. (So you must save it in the editing program and FSHPNGConverter )
Saving the FSH:
There are different Types of FSH, uncompressed/compressed and alpha/no-alpha and the combinations of the two. in FSHPNGConverter you just select Compressed or Uncompressed from the combobox at the bottom right.
It will see if there is an alpha or not.
The default is compressed.
You can also copy the FSH as a PNG file (that you can paste into explorer) onto the clipboard
Or copy the FSH as an image (that you can paste into MS paint etc) onto the clipboard.
You can also drag and drop FSH/PNGs onto the listview. And the program can have PNGs dragged onto it's icon/opened with it.
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fi200.photobucket.com%2Falbums%2Faa230%2FwarriorST%2FFSHPNGConverter.jpg&hash=66f65db4684214c820b301986c744ce6822f222c)
Jonathan
Jonathan
Getting a System.NullReferenceException when the form loads, it will run if continue is clicked.
Great, that's what I though I'd fixed.
EDIT: Forgot a Not :)
I've updated it and it's attached to the same post,
The Alpha from Transparency code contains another bug, it would not set the alpha map on semi-transparent sections of an image.
The fixed code is:
While testbmp.GetPixel(x, y).A < 255
testbmp.SetPixel(x, y, Color.FromArgb(srcpxl.A, srcpxl.A, srcpxl.A))
End While
Are you saying I should replace this:
While testbmp.GetPixel(x, y).A = 0 AndAlso testbmp.GetPixel(x, y).R = 0
testbmp.SetPixel(x, y, Color.Black)
End While
with that? Because you gave me this code.
And I'm not really sure what you mean by it would not set the alpha map on semi-transparent sections of an image? Is that opening or saving a FSH or a PNG?
It would be all of them.
The 24-bit fsh would need to have its alpha reset to white when loaded or it would cause the image to disappear when Alpha Blended.
Well I fixed the semi-transparency thing, though I didn't use your code as I said in the PM. Please let me know if that was wrong :)
Also added in a show Alpha button which shows you the alpha of the selected image (not when you've selected multiple though) in a little toolbox type window.
Also lets you save in 24-bit uncompressed properly, and thanks to null45's fix he sent me ages ago you can now open 24-bit uncompressed FSHs and they will be correct.
Before I reupload I'm going to add a an "Add alpha to image" button so that you can open a bitmap then right click it and choose an alpha for it.
Also going to add a quick edit feature, which works the same the quick convert does and will allow you to open in programs that do not support photoshop without seeing any of the FSHConverter program.
Also change the way the compression setting works, by making it remember if the FSH you opened was compressed or not. And make it easier to see which are compressed and which aren't.
Jonathan
Sounds good mate, looking forward to it :thumbsup:
Much smaller easier tool, going back to what I was originally wanting (simple tools to use FSH files)
Simply adds a convert button to the context menu and explorer bar to convert the FSH:
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fdl.dropbox.com%2Fu%2F2969879%2FPictures%2FFSHMenu.png&hash=63a63f2fd3c7521a9e5560c03048672ab0ea9b4e)
How did it take me 2 weeks to find this out. Thanks Jonathan... the right-click option is wonderful! &apls
Why is it claiming that Microsoft wrote it? ::)
Ah, great I'd thought I'd changed all that. :)