Class AbstractImageEncoder

  • All Implemented Interfaces:
    Encoder
    Direct Known Subclasses:
    PNGEncoder

    public abstract class AbstractImageEncoder
    extends java.lang.Object
    implements Encoder
    This is the base class for encoding a component to a stream file.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.awt.Image img  
      protected java.io.OutputStream ofile  
    • Method Summary

      Modifier and Type Method Description
      static byte byteFromChar​(char ochar)  
      static byte byteFromInt​(int value)  
      static byte[] bytesFromLong​(long value)  
      byte compressColor​(int clr)
      Compress the given color into one 8 bit representation.
      byte compressColor​(int red, int green, int blue)
      Compress the given color into one 8 bit representation.
      byte createByte​(int b7, int b6, int b5, int b4, int b3, int b2, int b1, int b0)  
      void encode​(java.awt.Component component, java.io.OutputStream os)
      Encode the specified component on the specified stream
      void encode​(java.awt.Image image, java.io.OutputStream os)  
      protected void error​(java.lang.String msg)  
      abstract void saveImage()  
      static java.awt.Image snapshot​(java.awt.Component component)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • img

        protected java.awt.Image img
      • ofile

        protected java.io.OutputStream ofile
    • Constructor Detail

      • AbstractImageEncoder

        public AbstractImageEncoder()
    • Method Detail

      • encode

        public void encode​(java.awt.Image image,
                           java.io.OutputStream os)
                    throws java.io.IOException,
                           EncoderException
        Throws:
        java.io.IOException
        EncoderException
      • encode

        public void encode​(java.awt.Component component,
                           java.io.OutputStream os)
                    throws java.io.IOException,
                           EncoderException
        Description copied from interface: Encoder
        Encode the specified component on the specified stream
        Specified by:
        encode in interface Encoder
        Parameters:
        component - component
        os - an outputstream
        Throws:
        java.io.IOException - an exception
        EncoderException - an encoder exception
      • snapshot

        public static java.awt.Image snapshot​(java.awt.Component component)
      • createByte

        public byte createByte​(int b7,
                               int b6,
                               int b5,
                               int b4,
                               int b3,
                               int b2,
                               int b1,
                               int b0)
      • byteFromInt

        public static byte byteFromInt​(int value)
      • bytesFromLong

        public static byte[] bytesFromLong​(long value)
      • byteFromChar

        public static byte byteFromChar​(char ochar)
      • compressColor

        public byte compressColor​(int clr)
        Compress the given color into one 8 bit representation.
        Parameters:
        clr - integer representation of rgb value (lowest byte is blue, second lowest byte is green, third lowest byte is red)
        Returns:
        color compressed into 8-bit representation
      • compressColor

        public byte compressColor​(int red,
                                  int green,
                                  int blue)
        Compress the given color into one 8 bit representation.
        Parameters:
        red - value of the red portion of the color
        green - value of the green portion of the color
        blue - value of the blue portion of the color
        Returns:
        color compressed into 8-bit representation