Class GifRecorder

java.lang.Object
org.openpatch.scratch.extensions.recorder.Recorder
org.openpatch.scratch.extensions.recorder.GifRecorder

public class GifRecorder extends Recorder
The GifRecorder class is responsible for recording and saving frames as GIF images. It extends the Recorder class and utilizes the AnimatedGifEncoder to create GIF files.

The class provides methods to start and stop the recording process, save individual frames, and capture snapshots as GIF images.

The GifRecorder class handles potential NullPointerExceptions that may occur during the frame saving process.

Example usage:


 GifRecorder recorder = new GifRecorder("output.gif");
 recorder.start();
 // Capture frames
 recorder.stop();
 
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static Color
    The transparent color used in the GIF image.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GifRecorder(String filePath)
    Constructs a new GifRecorder object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Saves the current frame of the applet as a GIF image.
    void
    Captures a snapshot and saves it as a GIF.
    void
    Starts the GIF recording process.
    void
    Stops the GIF recording process and finalizes the GIF file.

    Methods inherited from class org.openpatch.scratch.extensions.recorder.Recorder

    post

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • transparent

      public static Color transparent
      The transparent color used in the GIF image.
  • Constructor Details

    • GifRecorder

      public GifRecorder(String filePath)
      Constructs a new GifRecorder object.
      Parameters:
      filePath - the path where the GIF file will be saved
  • Method Details

    • saveFrame

      public void saveFrame()
      Saves the current frame of the applet as a GIF image.

      This method captures the current frame from the applet, sets the frame rate, and adds the frame to the GIF encoder. If the applet's pixels are null, the frame is not saved.

      Note: This method catches and ignores any NullPointerException that may occur.

      Specified by:
      saveFrame in class Recorder
    • snapshot

      public void snapshot()
      Captures a snapshot and saves it as a GIF. This method starts the GIF encoder, saves the current frame, and then finishes the encoding process.
    • start

      public void start()
      Starts the GIF recording process.
      Overrides:
      start in class Recorder
    • stop

      public void stop()
      Stops the GIF recording process and finalizes the GIF file.
      Overrides:
      stop in class Recorder