org.w3c.tools.jpeg
Class JpegCommentWriter

java.lang.Object
  |
  +--java.io.Writer
        |
        +--org.w3c.tools.jpeg.JpegCommentWriter

public class JpegCommentWriter
extends java.io.Writer

Allow you to write text comments to jpeg stream Some code has been adapted from wrjpgcom.c from The Independent JPEG Group


Fields inherited from class java.io.Writer
lock
 
Constructor Summary
JpegCommentWriter(java.io.OutputStream out, java.io.InputStream in)
          Create a JpegCommentWriter, using an Input stream as the jpeg binary source, and writing in the output stream
JpegCommentWriter(java.io.OutputStream out, java.io.InputStream in, java.lang.String enc)
          Create a JpegCommentWriter, using an Input stream as the jpeg binary source, and writing in the output stream
 
Method Summary
 void close()
           
protected  void dupFirstHeaders()
          the the first headers until a SOF parker is found
protected  int dupFirstMarker()
          copy the marker and return it
protected  void dupHeader(int marker)
          dup the marker and the body
 void flush()
           
 java.lang.String getEncoding()
          gets the encoding used by the comment writer
static void main(java.lang.String[] args)
          The usual debugging tool
protected  int nextMarker()
          get the next marker, and eat extra bytes
protected  int read2bytes()
          read 2 bytes and create an integer out of it
protected  void skipVariable()
          skip the body after a marker
 void write(char[] buffer)
          write an array of characters
 void write(char[] buffer, int off, int len)
          write a portion of an array of characters
 void write(int ch)
          write one character
 void write(java.lang.String s)
          Write a String
 void write(java.lang.String s, int off, int len)
          Write a portion of a String
protected  void writeMarker(int marker)
           
protected  void writeMarkerLength(int len)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JpegCommentWriter

public JpegCommentWriter(java.io.OutputStream out,
                         java.io.InputStream in)
Create a JpegCommentWriter, using an Input stream as the jpeg binary source, and writing in the output stream
Parameters:
out, - the output stream where the image will be written
in, - the input stream of the jpeg file, it MUST point to the beginning of the jpeg to avoid problems

JpegCommentWriter

public JpegCommentWriter(java.io.OutputStream out,
                         java.io.InputStream in,
                         java.lang.String enc)
                  throws java.io.UnsupportedEncodingException
Create a JpegCommentWriter, using an Input stream as the jpeg binary source, and writing in the output stream
Parameters:
out, - the output stream where the image will be written
in, - the input stream of the jpeg file, it MUST point to the beginning of the jpeg to avoid problems
enc, - the encoding name used when you write comments
Method Detail

getEncoding

public java.lang.String getEncoding()
gets the encoding used by the comment writer

write

public void write(int ch)
           throws java.io.IOException
write one character
Overrides:
write in class java.io.Writer

write

public void write(char[] buffer)
           throws java.io.IOException
write an array of characters
Overrides:
write in class java.io.Writer

write

public void write(char[] buffer,
                  int off,
                  int len)
           throws java.io.IOException
write a portion of an array of characters
Overrides:
write in class java.io.Writer

write

public void write(java.lang.String s)
           throws java.io.IOException
Write a String
Overrides:
write in class java.io.Writer

write

public void write(java.lang.String s,
                  int off,
                  int len)
           throws java.io.IOException
Write a portion of a String
Overrides:
write in class java.io.Writer

flush

public void flush()
           throws java.io.IOException
Overrides:
flush in class java.io.Writer

close

public void close()
           throws java.io.IOException
Overrides:
close in class java.io.Writer

dupFirstMarker

protected int dupFirstMarker()
                      throws java.io.IOException,
                             JpegException
copy the marker and return it

read2bytes

protected int read2bytes()
                  throws java.io.IOException,
                         JpegException
read 2 bytes and create an integer out of it

nextMarker

protected int nextMarker()
                  throws java.io.IOException
get the next marker, and eat extra bytes

skipVariable

protected void skipVariable()
                     throws java.io.IOException,
                            JpegException
skip the body after a marker

dupHeader

protected void dupHeader(int marker)
                  throws java.io.IOException,
                         JpegException
dup the marker and the body

writeMarker

protected void writeMarker(int marker)
                    throws java.io.IOException

writeMarkerLength

protected void writeMarkerLength(int len)
                          throws java.io.IOException

dupFirstHeaders

protected void dupFirstHeaders()
                        throws java.io.IOException
the the first headers until a SOF parker is found

main

public static void main(java.lang.String[] args)
The usual debugging tool