Class RawCodec

All Implemented Interfaces:
Codec

public class RawCodec extends AbstractVideoCodec
RawCodec encodes a BufferedImage as a byte[] array.

This codec does not encode the color palette of an image. This must be done separately.

The pixels of a frame are written row by row from top to bottom and from the left to the right.

Supported input formats:

  • VideoFormat onlyWith BufferedImage.class, any width, any height, depth=4.
Supported output formats:
  • VideoFormat onlyWith byte[].class, same width and height as input format, depth=4.
Author:
Werner Randelshofer
  • Constructor Details

    • RawCodec

      public RawCodec()
  • Method Details

    • setOutputFormat

      public Format setOutputFormat(Format f)
      Description copied from interface: Codec
      Sets the output format. Returns the format that was actually set. This is the closest format that the Codec supports. Returns null if the specified format is not supported and no reasonable match could be found.
      Specified by:
      setOutputFormat in interface Codec
      Overrides:
      setOutputFormat in class AbstractCodec
    • writeKey8

      public void writeKey8(OutputStream out, byte[] data, int width, int height, int offset, int scanlineStride) throws IOException
      Encodes an 8-bit key frame.
      Parameters:
      out - The output stream.
      data - The image data.
      width - The width of the image in data elements.
      height - The height of the image in data elements.
      offset - The offset to the first pixel in the data array.
      scanlineStride - The number to append to offset to get to the next scanline.
      Throws:
      IOException
    • writeKey16

      public void writeKey16(OutputStream out, short[] data, int width, int height, int offset, int scanlineStride) throws IOException
      Encodes a 24-bit key frame.
      Parameters:
      out - The output stream.
      data - The image data.
      width - The width of the image in data elements.
      height - The height of the image in data elements.
      offset - The offset to the first pixel in the data array.
      scanlineStride - The number to append to offset to get to the next scanline.
      Throws:
      IOException
    • writeKey24

      public void writeKey24(OutputStream out, int[] data, int width, int height, int offset, int scanlineStride) throws IOException
      Encodes a 24-bit key frame.
      Parameters:
      out - The output stream.
      data - The image data.
      width - The width of the image in data elements.
      height - The height of the image in data elements.
      offset - The offset to the first pixel in the data array.
      scanlineStride - The number to append to offset to get to the next scanline.
      Throws:
      IOException
    • writeKey32

      public void writeKey32(OutputStream out, int[] data, int width, int height, int offset, int scanlineStride) throws IOException
      Encodes a 24-bit key frame.
      Parameters:
      out - The output stream.
      data - The image data.
      width - The width of the image in data elements.
      height - The height of the image in data elements.
      offset - The offset to the first pixel in the data array.
      scanlineStride - The number to append to offset to get to the next scanline.
      Throws:
      IOException
    • writeKey24

      public void writeKey24(OutputStream out, BufferedImage image) throws IOException
      Encodes a 24-bit key frame.
      Parameters:
      out - The output stream.
      image - The image.
      Throws:
      IOException
    • process

      public int process(Buffer in, Buffer out)
      Description copied from interface: Codec
      Performs the media processing defined by this codec.

      Copies the data from the input buffer into the output buffer.

      Returns:
      A combination of processing flags.