MaxScript生成Gif

需要用到一个NGif的库,是国人编写的,不过到我写这个帖子的时候还不是以dll文件的方式提供,是给出的代码。这里我编译了一个dll.

http://files.cnblogs.com/sitt/NGifDll.zip

这个dll文件需要和脚本在同目录执行,脚本需要保存下,或者读者自己修改一下DotNet.LoadAssembly

简单的生成Gif的MaxScript如下

ContractedBlock.gif ExpandedBlockStart.gif 生成Gif
localPath = GetFilenamePath (GetSourceFileName())
DotNet.LoadAssembly (localPath
+ "Ngif.dll")
GifEncoder
= DotNetObject "NGif.AnimatedGifEncoder"
DotNetImage
= DotNetClass "System.Drawing.Image"
theGifFileName
= "d:\\test.gif"
gifFrames
= #("d:\\01.png","d:\\02.png","d:\\03.png")
GifEncoder.Start(theGifFileName )
GifEncoder.SetDelay(
500);
GifEncoder.SetRepeat(
0);
for tempframe in gifFrames do
(
tempImage
= DotNetImage.FromFile tempframe
GifEncoder.AddFrame tempImage
tempImage.Dispose()
)
GifEncoder.Finish()

  

ContractedBlock.gif ExpandedBlockStart.gif 渲染至Gif
localPath = GetFilenamePath (GetSourceFileName())
DotNet.LoadAssembly (localPath
+ "Ngif.dll")
GifEncoder
= DotNetObject "NGif.AnimatedGifEncoder"
DotNetImage
= DotNetClass "System.Drawing.Image"
theGifFileName
= "d:\\test.gif"
GifEncoder.Start(theGifFileName )
GifEncoder.SetDelay(
40);
GifEncoder.SetRepeat(
0);

timeStart
= AnimationRange.Start.Frame
timeEnd
= AnimationRange.End.Frame

for i = timeStart to timeEnd do
(
SliderTime
= i
tempframe
= "d:\\test.png"
render outputfile:tempframe vfb:
false
tempImage
= DotNetImage.FromFile tempframe
GifEncoder.AddFrame tempImage
tempImage.Dispose()
)
GifEncoder.Finish()

  

转载于:https://www.cnblogs.com/sitt/archive/2011/08/19/2145564.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值