WidgetWorking

I am working on an image editing application and am on the final step, which is the user saves the 3 images they have edited as one animated gif. I have done a lot of web searches trying to find some code that will accomplish this, but have come up empty.

Is it possible If so, how is it done



Re: Visual Basic Express Edition Save As animated gif impossible?


Re: Visual Basic Express Edition Save As animated gif impossible?

WidgetWorking

The code will load and display an animated gif. I need to combine 3 individual images into one animated gif, then let the user save it to his hard drive.



Re: Visual Basic Express Edition Save As animated gif impossible?


Re: Visual Basic Express Edition Save As animated gif impossible?

WidgetWorking

I got the NGif code, now I am supposed to revise it so it will work in VB Express. I removed most of the ; and ended up with the code below. I know html and have only been trying to learn VB Express for a few days, so when it comes to revising code, I haven't a clue. It's discouraging because my application is almost finished, except for this animated gif thing. These are the error messages I receive on the code:

"Declaration Expected" error on AnimatedGifEncoder, e, GifDecoder, Image and frame
"Statement Cannot Appear Outside A Method Body" error on For.
"Syntax" error on String and +.

Public Class Form1
' Points of Interest:
' Use Stream to replace BinaryWriter when you write a fixed-byte structured binary file.
' * create Gif *
' you should replace filepath

String [] imageFilePaths = new String[]{"c:\\01.png","c:\\02.png","c:\\03.png"}
String outputFilePath = "c:\\test.gif"

AnimatedGifEncoder e = new AnimatedGifEncoder()
e.Start( outputFilePath )
e.SetDelay(500)
' -1:no repeat,0:always repeat
e.SetRepeat(0)
For (int i = 0, count = imageFilePaths.Length; i < count; i++ )

e.AddFrame( Image.FromFile( imageFilePathsIdea ) )
e.Finish()
' * extract Gif *
string outputPath = "c:\\"

GifDecoder gifDecoder = new GifDecoder()
gifDecoder.Read( "c:\\test.gif" )
For ( int i = 0, count = gifDecoder.GetFrameCount(); i < count; i++ )

Image frame = gifDecoder.GetFrame( i ); // frame i
frame.Save( outputPath + Guid.NewGuid().ToString()
+ ".png", ImageFormat.Png )
End Class





Re: Visual Basic Express Edition Save As animated gif impossible?

ReneeC

 

Hey Widget.... We could working on this together. The first thing to know about C is that their syntax is backwards.

Private Sub ProcessFiles()

'String [] imageFilePaths

'really means

Dim imageFilePaths () as string = {"c:\01.png","c:\02.png","c:\03.png"}  ' See there are infiltrating VB with squiggles

'This is the largest conversion concept for the whole file.

'String outputFilePath = "c:\test.gif"

'really means

Dim outputFilePath as string = "c:\test.gif"

'AnimatedGifEncoder e = new AnimatedGifEncoder()

'really means

Dim e as new AnimatedGifEncoder()


e.Start( outputFilePath )
e.SetDelay(500)
    ' -1:no repeat,0:always repeat
e.SetRepeat(0)

'These are fine. Now for icky stuff.... C loops

'For (int i = 0, count = imageFilePaths.Length; i < count; i++ )

dim count as integer = gifDecoder.Read( "c:\test.gif" )

For i as integer = 0 to count-1 

  e.AddFrame( Image.FromFile( imageFilePaths(i) ) );

next

e.Finish()

 
e.Finish()
    ' * extract Gif * is okay


Dim outputPath as string = "c:\\"

'Warning: Watch for tricks with case sensitivity

'GifDecoder gifDecoder = new GifDecoder()

Dim gifDecoder as New GifDecoder

gifDecoder.Read( "c:\test.gif" )   ' is ok

count = gifDecoder.GetFrameCount()

DIm Frame as Image

For i as integer = 0 to count-1 

frame = gifDecoder.GetFrame( i )

frame.Save( outputPath + Guid.NewGuid().ToString() + ".png", ImageFormat.Png )

Next

 

End Sub

 






Re: Visual Basic Express Edition Save As animated gif impossible?

WidgetWorking

On this line of code:
Dim e As New AnimatedGifEncoder()
I get this error: Type 'AnimatedGifEncoder' is not defined.

On this line of code:
Dim gifDecoder As New GifDecoder
I get this error: Type 'GifDecoder' is not defined.

On this line of code:
Frame.Save(outputPath + Guid.NewGuid().ToString() + ".png", ImageFormat.Png)
I get this error: 'ImageFormat' is not delared.

Public Class Form1

Private Sub ProcessFiles()
Dim imageFilePaths() As String = {"c:\01.png", "c:\02.png", "c:\03.png"}
Dim outputFilePath As String = "c:\test.gif"
Dim e As New AnimatedGifEncoder()
Dim gifDecoder As New GifDecoder

e.Start(outputFilePath)
e.SetDelay(500)
' -1:no repeat,0:always repeat
e.SetRepeat(0)

Dim count As Integer = gifDecoder.Read("c:\test.gif")
For i As Integer = 0 To count - 1

e.AddFrame(Image.FromFile(imageFilePaths(i)))
Next

e.Finish()

' * extract Gif *
Dim outputPath As String = "c:\\"

gifDecoder.Read("c:\test.gif")
count = gifDecoder.GetFrameCount()

Dim Frame As Image
For i As Integer = 0 To count - 1
Frame = gifDecoder.GetFrame(i)
Frame.Save(outputPath + Guid.NewGuid().ToString() + ".png", ImageFormat.Png)
Next
End Sub
End Class





Re: Visual Basic Express Edition Save As animated gif impossible?

ReneeC

I translated the subroutine for you. You have some missing classes like: AnimatedGifEncoder and GifDecoder

and I think I may know why. Gif file designed are owned by Unisys. Gif Encoders and Decoders in code cost money. There are to my knowledge no Gif encoders in Dot Net. In other words you can't create a gif file from some random imgae where you can for other formats.

Also you are missing a standard Dot Net import declaration probably in the system.drawing Namespace which is the last of your worries right now. I have a feeling that these are the top level classes and the real hard working engines have yet to be uncovered by you. They are probably large and ponderous or they may be in a DLL. I don't know.






Re: Visual Basic Express Edition Save As animated gif impossible?

WidgetWorking

Since I can't do that, if I were to programmically open Microsoft GIFAnimator:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
Shell("c:\Program Files\Microsoft Gif Animator\GIFAnimator.exe")
End Sub
End Class

Once I have open it, instead of physically using MS Gif Animator itself, can I type code in VB Express to specify which image goes where, what the timing is, etc. In other words, I know I can open it programmically, but can I also use the MS Gif Animator program programmically





Re: Visual Basic Express Edition Save As animated gif impossible?

ReneeC

Perhaps IF it has a rich command line interface which I would tend to doubt.

Wow, I just read up on this on the net. Next to none is producing code for people to integrate. I am terribly sorry. I wish I had better news for you.






Re: Visual Basic Express Edition Save As animated gif impossible?

WidgetWorking

Since I can open MS Gif Animator programattically, I can live without being able to run it from VB Express, although I'm sure there would be a lot of happy people if someone could figure out how to do it and share their secret with the rest of us. I do appreciate all of your time and help.



Re: Visual Basic Express Edition Save As animated gif impossible?

ReneeC

You are more than welcome.