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?

October 23, 2021, 08:04:09 PM

Login with username, password and session length

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

0 Members and 1 Guest are viewing this topic.

Offline puresim

Re: Simple FSH<>PNG Tools
« Reply #40 on: January 14, 2010, 04:19:51 PM »
Sorry for the delay. I do get that error dialog when I drop the fsh files.



Seems like Reader isn't saving the files properly. Thanks null45, I'll try to work it out.

Offline Jonathan

  • NAM Team
  • Forums Guru
  • *
  • Posts: 2609
  • Total likes: 6
  • Reputation: 25
  • CL: Einstein, Jr. &scl()
Re: Simple FSH<>PNG Tools
« Reply #41 on: January 16, 2010, 06: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?

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:


Jonathan

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 #42 on: January 17, 2010, 12:44:38 AM »
The program would not crash if the code is encased in a try catch block eg.

Code: [Select]
<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:

Offline puresim

Re: Simple FSH<>PNG Tools
« Reply #43 on: January 17, 2010, 02:02:46 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.
« Last Edit: January 18, 2010, 01:48:46 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 #44 on: January 17, 2010, 08:05:58 PM »
Both of those fsh files are valid and work fine for me.

What error does FiSHMan give?


Offline puresim

Re: Simple FSH<>PNG Tools
« Reply #45 on: January 18, 2010, 01:53:22 PM »
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 :)

Offline Jonathan

  • NAM Team
  • Forums Guru
  • *
  • Posts: 2609
  • Total likes: 6
  • Reputation: 25
  • CL: Einstein, Jr. &scl()
Re: Simple FSH<>PNG Tools
« Reply #46 on: January 18, 2010, 02:14:29 PM »
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.

Offline puresim

Re: Simple FSH<>PNG Tools
« Reply #47 on: January 18, 2010, 02:48:26 PM »
This is embarassing but that just worked &ops I was 99.9% sure that was the latest FSHLib.dll file!

Thanks all!

Offline Jonathan

  • NAM Team
  • Forums Guru
  • *
  • Posts: 2609
  • Total likes: 6
  • Reputation: 25
  • CL: Einstein, Jr. &scl()
FSH Converter Tool
« Reply #48 on: February 15, 2010, 12:09:59 PM »
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.



Jonathan

Offline puresim

Re: Simple FSH<>PNG Tools
« Reply #49 on: February 15, 2010, 02:13:33 PM »
That's a lot of useful new features! :thumbsup: Looks really simple to use from the screenshot - Where can we download it from?

Offline Jonathan

  • NAM Team
  • Forums Guru
  • *
  • Posts: 2609
  • Total likes: 6
  • Reputation: 25
  • CL: Einstein, Jr. &scl()
Re: Simple FSH<>PNG Tools
« Reply #50 on: February 22, 2010, 04:38:37 PM »
I run into a last minute problem, that I need to fix but don't have the time until this weekend.

Offline Jonathan

  • NAM Team
  • Forums Guru
  • *
  • Posts: 2609
  • Total likes: 6
  • Reputation: 25
  • CL: Einstein, Jr. &scl()
FSH Converter Tool - Attached
« Reply #51 on: February 28, 2010, 04:06:45 AM »
Here is the FSHConverter Tool, finally got round to fixing the issue.

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.



Jonathan

Jonathan

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 #52 on: February 28, 2010, 02:12:16 PM »
Getting a System.NullReferenceException when the form loads, it will run if continue is clicked.


Offline Jonathan

  • NAM Team
  • Forums Guru
  • *
  • Posts: 2609
  • Total likes: 6
  • Reputation: 25
  • CL: Einstein, Jr. &scl()
Re: Simple FSH<>PNG Tools
« Reply #53 on: February 28, 2010, 02:16:11 PM »
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,

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 #54 on: February 28, 2010, 02:29:55 PM »
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:

Code: [Select]
    While testbmp.GetPixel(x, y).A < 255
        testbmp.SetPixel(x, y, Color.FromArgb(srcpxl.A, srcpxl.A, srcpxl.A))
   End While


Offline Jonathan

  • NAM Team
  • Forums Guru
  • *
  • Posts: 2609
  • Total likes: 6
  • Reputation: 25
  • CL: Einstein, Jr. &scl()
Re: Simple FSH<>PNG Tools
« Reply #55 on: February 28, 2010, 02:31:35 PM »
Are you saying I should replace this:
Code: [Select]
  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?

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 #56 on: February 28, 2010, 02:44:09 PM »
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.


« Last Edit: March 02, 2010, 09:31:29 PM by null45 »

Offline Jonathan

  • NAM Team
  • Forums Guru
  • *
  • Posts: 2609
  • Total likes: 6
  • Reputation: 25
  • CL: Einstein, Jr. &scl()
Re: Simple FSH<>PNG Tools
« Reply #57 on: March 05, 2010, 05:22:29 PM »
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

Offline puresim

Re: Simple FSH<>PNG Tools
« Reply #58 on: March 06, 2010, 08:30:41 AM »
Sounds good mate, looking forward to it :thumbsup:

Offline Jonathan

  • NAM Team
  • Forums Guru
  • *
  • Posts: 2609
  • Total likes: 6
  • Reputation: 25
  • CL: Einstein, Jr. &scl()
Re: Simple FSH<>PNG Tools
« Reply #59 on: April 24, 2010, 04:23:02 AM »
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: