有没有办法改变 GIF 速度



我想尝试以gifspeed保存,可能会弹出一个带有速度选择的框,尽管我不太确定如何使用java更改gif速度。

我已经查过了,但无济于事。我是新手,所以如果这是一个问题,我很抱歉,我只是没有找到它


import base.AnimationExporter;
import java.awt.Dimension;
import java.awt.Graphics;
import settings.GuiDrawer;
public class SaveButton extends GuiElement
{
  public SaveButton(GuiMenu parent)
  {
    super(parent);
  }
  public void releasedOn(int posX, int posY, int button)
  {
    if (heldDown) {
      heldDown = false;
      AnimationExporter.saveAnimation(true);
    }
  }
}

编辑:我的坏在这里动画导出器

   try {
     ImageWriter gifWriter = (ImageWriter)ImageIO.getImageWritersByFormatName("gif").next();
     ImageOutputStream outputStream = ImageIO.createImageOutputStream(outputFile);
     gifWriter.setOutput(outputStream);
     ImageTypeSpecifier imageType = ImageTypeSpecifier.createFromBufferedImageType(2);
     IIOMetadata metadata = gifWriter.getDefaultImageMetadata(imageType, null);
     IIOMetadataNode nodeTree = (IIOMetadataNode)metadata.getAsTree(metadata.getNativeMetadataFormatName());
     IIOMetadataNode appExtensionsNode = getNode("ApplicationExtensions", nodeTree);
     IIOMetadataNode child = new IIOMetadataNode("ApplicationExtension");
     child.setAttribute("applicationID", "NETSCAPE");
     child.setAttribute("authenticationCode", "2.0");
     child.setUserObject(new byte[] { 1, (byte)((Editing.animationLoop ? 0 : 1) & 0xFF), (byte)((Editing.animationLoop ? 0 : 1) >> 8 & 0xFF) });
     appExtensionsNode.appendChild(child);
     metadata.setFromTree(metadata.getNativeMetadataFormatName(), nodeTree);
     gifWriter.prepareWriteSequence(null);
     for (Frame frame : animation.Animation.frames) {
       IIOMetadata imageMetadata = gifWriter.getDefaultImageMetadata(imageType, null);
       IIOMetadataNode imageNodeTree = (IIOMetadataNode)imageMetadata.getAsTree(imageMetadata.getNativeMetadataFormatName());
       IIOMetadataNode graphicNode = getNode("GraphicControlExtension", imageNodeTree);
       graphicNode.setAttribute("disposalMethod", "none");
       graphicNode.setAttribute("userInputFlag", "FALSE");
       graphicNode.setAttribute("delayTime", Integer.toString(delay));
       imageMetadata.setFromTree(imageMetadata.getNativeMetadataFormatName(), imageNodeTree);
       IIOImage currentImage = new IIOImage(frame.getEntireFrame(), null, imageMetadata);
       gifWriter.writeToSequence(currentImage, null);
     }
     gifWriter.endWriteSequence();
     outputStream.close();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }```
嵌入了

"GIF"的帧率。但是,您可以通过外部工具加快或减慢速度。Photoshop可能效果最好。此工具也许能够为您提供帮助。如果您需要动态帧速率更改,我们需要有关您正在使用的库的更多信息。

啊,对不起,我以为我抄的少了,我现在觉得自己很笨,delayTime这里是,

public int delay = Editing.frameDelay;我认为frameDelay是我应该改变的 public static int frameDelay = 100;

最新更新