zoukankan      html  css  js  c++  java
  • MaxScript生成Gif

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

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

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

    简单的生成Gif的MaxScript如下

    生成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()

      

    渲染至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()

      

  • 相关阅读:
    stc单品机的命名规则
    代码导入单片机运行
    openlayers tips
    LeetCode 766. Toeplitz Matrix
    【题集】二叉树的遍历各类题型汇总
    LeetCode 821. Shortest Distance to a Character
    关于C++中vector<vector<int> >的使用
    POJ
    LeetCode#155 Min Stack
    LeetCode#160 Intersection of Two Linked Lists
  • 原文地址:https://www.cnblogs.com/sitt/p/2145564.html
Copyright © 2011-2022 走看看