Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
stan  
#1 Posted : Saturday, August 19, 2006 5:58:01 AM(UTC)
stan

Rank: Member

Groups: Member
Joined: 8/19/2006(UTC)
Posts: 7

For example, there are 3 JPG pictures.
Now, create a blank gif with 600*500
add the jpg1 to 1-5 frames, add jpg2 to 6-10 frames, add jpg3 to 11-15 frames.

Can this COM do this?
Andrew  
#2 Posted : Sunday, August 20, 2006 1:37:14 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
Stan,

There is a class called GifWriter.

It can create animated GIFs. It is used in the following way:

1. Open GifWriter with OpenFile method.
2. Create instances of GifFrame class, initialize its properties.
3. Add these frames using AddFrame method.
4. When you added all necessary frames, call Close method.

Not sure why it is necessary to add the same image several times. It will noticeable increase GIF size. Instead of it you can configure delay of the frame.

Example (ASP, VBScript):

Code:
<%
Dim objGifWriter, objGifFrame, objBitmap
Set objGifWriter = Server.CreateObject("MultiImage.GifWriter")
Set objGifFrame = Server.CreateObject("MultiImage.Frame")
Set objBitmap = Server.CreateObject("GraphicsMill.Bitmap")

objGifWriter.OpenFile "c:\temp\animated.gif", 600, 500
objGifWriter.IsLzwEnabled = true

' Add frame 1
objBitmap.LoadFromFile "C:\[Test Files]\1.jpg"
objBitmap.Data.ConvertTo8bppIndexed
Set objGifFrame.Bitmap = objBitmap
objGifFrame.Delay = 300
objGifWriter.AddFrame objGifFrame

' Add frame 2
objBitmap.LoadFromFile "C:\[Test Files]\2.jpg"
objBitmap.Data.ConvertTo8bppIndexed
Set objGifFrame.Bitmap = objBitmap
objGifFrame.Delay = 100
objGifWriter.AddFrame objGifFrame

'...

objGifWriter.Close
%>


Hope this helps.

Edited by user Tuesday, December 15, 2009 10:41:03 AM(UTC)  | Reason: Not specified

stan  
#3 Posted : Sunday, August 20, 2006 5:47:47 PM(UTC)
stan

Rank: Member

Groups: Member
Joined: 8/19/2006(UTC)
Posts: 7

well, cool, it works perfect. That is what I want.

Your COM is number one. but the reference book is not so good. It is hard to get help on help file. For example I search "AddFrame" on the help file, only show these results:
Code:
[Visual Basic 6]
Sub AddFrame ( _
   ByVal frame As IFrame _
)
[VB Script]
Sub AddFrame ( _
   ByVal frame _
)

 IFormatWriter  Method AddFrame  
 AddFrame Adds a new frame to the media file. 


There is no any sample code for beginner.
Any way, it is perfect. I am talking with our hosting provider now. seem they dont like to install a COM. Once they agree for installing it, I will buy it for sure.

Another question is how to make fade out? for this example, there 2 jpg were added on this gif. I want them show fade out. Can this software do it?
I search "FADE" in help file get nothing.

Edited by user Wednesday, December 19, 2007 3:05:12 PM(UTC)  | Reason: Not specified

Andrew  
#4 Posted : Sunday, August 20, 2006 11:20:22 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
Stan,

To emulate fade out effect, you can create several intermediate frames by blending these jpegs with different alpha (opacity) value.

In other words, you can make a loop that will generate, say, 4 intermediate frames blended with opacity equal to 100, 75, 50, and 25.

Hope this helps.

Edited by user Tuesday, December 15, 2009 10:41:29 AM(UTC)  | Reason: Not specified

stan  
#5 Posted : Monday, August 21, 2006 1:10:26 AM(UTC)
stan

Rank: Member

Groups: Member
Joined: 8/19/2006(UTC)
Posts: 7

For example, there are 3 jpg files, 3.jpg, 4.jpg, 5.jpg. I creat the codes like this:

Code:
<%
Dim objGifWriter, objGifFrame, objBitmap
Set objGifWriter = Server.CreateObject("MultiImage.GifWriter")
Set objGifFrame = Server.CreateObject("MultiImage.Frame")
Set objBitmap = Server.CreateObject("GraphicsMill.Bitmap")

objGifWriter.OpenFile Server.MapPath("animated.gif"), 240, 240
objGifWriter.IsLzwEnabled = true

objBitmap.LoadFromFile Server.MapPath("3.jpg")
objBitmap.Transforms.Resize 240,240
objBitmap.SaveToFile Server.MapPath("3a.jpg")

objBitmap.LoadFromFile Server.MapPath("3a.jpg")
objBitmap.DrawOnBitmap objBitmap, , , , , , , , , CombineModeAlpha, 75
objBitmap.SaveToFile Server.MapPath("3b.jpg")

objBitmap.LoadFromFile Server.MapPath("3b.jpg")
objBitmap.DrawOnBitmap objBitmap, , , , , , , , , CombineModeAlpha, 50
objBitmap.SaveToFile Server.MapPath("3c.jpg")

objBitmap.LoadFromFile Server.MapPath("3c.jpg")
objBitmap.DrawOnBitmap objBitmap, , , , , , , , , CombineModeAlpha, 25
objBitmap.SaveToFile Server.MapPath("3d.jpg")


objBitmap.LoadFromFile Server.MapPath("4.jpg")
objBitmap.Transforms.Resize 240,240
objBitmap.SaveToFile Server.MapPath("4a.jpg")

objBitmap.LoadFromFile Server.MapPath("5.jpg")
objBitmap.Transforms.Resize 240,240
objBitmap.SaveToFile Server.MapPath("5a.jpg")

objBitmap.LoadFromFile Server.MapPath("3a.jpg")
objBitmap.Data.ConvertTo8bppIndexed
Set objGifFrame.Bitmap = objBitmap
objGifFrame.Delay = 300
objGifWriter.AddFrame objGifFrame

objBitmap.LoadFromFile Server.MapPath("3a.jpg")
objBitmap.Data.ConvertTo8bppIndexed
Set objGifFrame.Bitmap = objBitmap
objGifFrame.Delay = 100
objGifFrame.Delay = 300
objGifWriter.AddFrame objGifFrame
objBitmap.LoadFromFile Server.MapPath("3b.jpg")
objBitmap.Data.ConvertTo8bppIndexed
Set objGifFrame.Bitmap = objBitmap
objGifFrame.Delay = 100
objGifWriter.AddFrame objGifFrame
objBitmap.LoadFromFile Server.MapPath("3c.jpg")
objBitmap.Data.ConvertTo8bppIndexed
Set objGifFrame.Bitmap = objBitmap
objGifFrame.Delay = 100
objGifWriter.AddFrame objGifFrame

objBitmap.LoadFromFile Server.MapPath("3d.jpg")
objBitmap.Data.ConvertTo8bppIndexed
Set objGifFrame.Bitmap = objBitmap
objGifFrame.Delay = 100
objGifWriter.AddFrame objGifFrame

' Add frame 1
objBitmap.LoadFromFile Server.MapPath("4a.jpg")
objBitmap.Data.ConvertTo8bppIndexed
Set objGifFrame.Bitmap = objBitmap
objGifFrame.Delay = 300
objGifWriter.AddFrame objGifFrame

' Add frame 1
objBitmap.LoadFromFile Server.MapPath("5a.jpg")
objBitmap.Data.ConvertTo8bppIndexed
Set objGifFrame.Bitmap = objBitmap
objGifFrame.Delay = 300
objGifWriter.AddFrame objGifFrame
'...

objGifWriter.Close
response.Write("<img src='animated.gif'>")
%>


So now, from frame #1-#5, it shows 3.jpg, 3a.jpg, 3b.jpg, 3c.jpg and 3d.jpg for fading out. but the frame#1 is still on background so that it doesnt show fading out result. How to take off the frame#1 on frame#2, same to take off frame#1-2 on fram#3....How can it show like this:

Frame#1: 3.jpg
Frame#2: 3a.jpg, no 3.jpg background
Frame#3: 3b.jpg, no 3.jpg, 3a.jpg background
....
same to frame#5

Edited by user Wednesday, October 29, 2008 2:34:59 AM(UTC)  | Reason: Not specified

Valentina  
#6 Posted : Monday, August 21, 2006 2:52:57 PM(UTC)
Valentina

Rank: Member

Groups: Member
Joined: 8/21/2006(UTC)
Posts: 1

Please, look at the following sample. It should solve your problem, if I've understood you correctly :)

Code:

<%
Dim objGifWriter, objGifFrame, objBitmap1, objBitmap2
Set objGifWriter = Server.CreateObject("MultiImage.GifWriter")
Set objGifFrame = Server.CreateObject("MultiImage.Frame")
Set objBitmap1 = Server.CreateObject("GraphicsMill.Bitmap")
Set objBitmap2 = Server.CreateObject("GraphicsMill.Bitmap")

'Create an array of all files that will be used
Dim arrFiles(2)
arrFiles(0) = "C:\1.jpg"
arrFiles(1) = "C:\2.jpg"
arrFiles(2) = "C:\3.jpg"

objGifWriter.OpenFile "c:\temp\animated.gif", 100, 100
objGifWriter.IsLzwEnabled = true

'Loop through all files and blend them
For i = LBound(arrFiles) To Ubound(arrFiles)-1
	'Draw the image as is
	objBitmap1.LoadFromFile arrFiles(i)
	objBitmap1.Data.ConvertTo8bppIndexed
	Set objGifFrame.Bitmap = objBitmap1
	objGifWriter.AddFrame objGifFrame
	'Load the next image
	objBitmap2.LoadFromFile arrFiles(i+1)
	'Blend two images with different opacities
	For opacity = 25 To 100 Step 25
		'Re-load the first image, as objBitmap1 was changed
		objBitmap1.LoadFromFile arrFiles(i)
		'Blend
		objBitmap2.DrawOnBitmap objBitmap1,,,,,,,,,CombineModeAlpha,opacity
		objBitmap1.Data.ConvertTo8bppIndexed
		Set objGifFrame.Bitmap = objBitmap1
		objGifWriter.AddFrame objGifFrame
	Next
Next

'Draw the last image as is
objBitmap1.LoadFromFile arrFiles(Ubound(arrFiles))
objBitmap1.Data.ConvertTo8bppIndexed
Set objGifFrame.Bitmap = objBitmap1
objGifWriter.AddFrame objGifFrame

objGifWriter.Close
%>
valia
stan  
#7 Posted : Tuesday, August 22, 2006 4:07:16 PM(UTC)
stan

Rank: Member

Groups: Member
Joined: 8/19/2006(UTC)
Posts: 7

No, it shows the same thing. I am sorry that I might not say it clearly.
Let me say it at simple way.

Let's start from 1 picture.1.jpg
I want this picture resized and added in one GIF. and delay 1 second then fade out.

Now, add into gif is ok.
the problem is fading out. From my code on last reply:

1.jpg: frame#1 delay, then frame#2 75% Cap, frame#3 50% CAP, Frame #4 75% CAP. But the problem is that frame#1 is still on background, so frame#2-4 are just over the frame#1. So it does not show fade out.
Andrew  
#8 Posted : Wednesday, August 23, 2006 11:51:45 AM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
What you mean by "fade out"? Do you mean that it should be drawn on, say, black background instead of the previous frame (like the attached file)? In this case you should just create empty bitmap instead of loading it from file.

Just modify Valentina's code as highlighted with bold:

Code:
	For opacity = 25 To 100 Step 25
		'Re-load the first image, as objBitmap1 was changed
		'objBitmap1.LoadFromFile arrFiles(i)
		objBitmap1.CreateNew objBitmap2.Data.Width, objBitmap2.Data.Height, Format24bppRgb, ColorBlack
		'Blend
		objBitmap2.DrawOnBitmap objBitmap1,,,,,,,,,CombineModeAlpha,opacity
		objBitmap1.Data.ConvertTo8bppIndexed
		Set objGifFrame.Bitmap = objBitmap1
		objGifWriter.AddFrame objGifFrame
	Next


If we still misunderstood you, please attach an example of GIF image you are going to get.

Edited by user Wednesday, December 19, 2007 3:05:57 PM(UTC)  | Reason: Not specified

Andrew attached the following image(s):
animated-2.gif
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.