< prev index next >

src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JFIFMarkerSegment.java

Print this page




  73     int resUnits;
  74     int Xdensity;
  75     int Ydensity;
  76     int thumbWidth;
  77     int thumbHeight;
  78     JFIFThumbRGB thumb = null;  // If present
  79     ArrayList<JFIFExtensionMarkerSegment> extSegments = new ArrayList<>();
  80     ICCMarkerSegment iccSegment = null; // optional ICC
  81     private static final int THUMB_JPEG = 0x10;
  82     private static final int THUMB_PALETTE = 0x11;
  83     private static final int THUMB_UNASSIGNED = 0x12;
  84     private static final int THUMB_RGB = 0x13;
  85     private static final int DATA_SIZE = 14;
  86     private static final int ID_SIZE = 5;
  87     private final int MAX_THUMB_WIDTH = 255;
  88     private final int MAX_THUMB_HEIGHT = 255;
  89 
  90     private final boolean debug = false;
  91 
  92     /**
  93      * Set to <code>true</code> when reading the chunks of an
  94      * ICC profile.  All chunks are consolidated to create a single
  95      * "segment" containing all the chunks.  This flag is a state
  96      * variable identifying whether to construct a new segment or
  97      * append to an old one.
  98      */
  99     private boolean inICC = false;
 100 
 101     /**
 102      * A placeholder for an ICC profile marker segment under
 103      * construction.  The segment is not added to the list
 104      * until all chunks have been read.
 105      */
 106     private ICCMarkerSegment tempICCSegment = null;
 107 
 108 
 109     /**
 110      * Default constructor.  Used to create a default JFIF header
 111      */
 112     JFIFMarkerSegment() {
 113         super(JPEG.APP0);


 577         jfxx.write(ios, writer);
 578         writer.thumbnailComplete();
 579     }
 580 
 581 
 582     /**
 583      * Return an RGB image that is the expansion of the given grayscale
 584      * image.
 585      */
 586     private static BufferedImage expandGrayThumb(BufferedImage thumb) {
 587         BufferedImage ret = new BufferedImage(thumb.getWidth(),
 588                                               thumb.getHeight(),
 589                                               BufferedImage.TYPE_INT_RGB);
 590         Graphics g = ret.getGraphics();
 591         g.drawImage(thumb, 0, 0, null);
 592         return ret;
 593     }
 594 
 595     /**
 596      * Writes out a default JFIF marker segment to the given
 597      * output stream.  If <code>thumbnails</code> is not <code>null</code>,
 598      * writes out the set of thumbnail images as JFXX marker segments, or
 599      * incorporated into the JFIF segment if appropriate.
 600      * If <code>iccProfile</code> is not <code>null</code>,
 601      * writes out the profile after the JFIF segment using as many APP2
 602      * marker segments as necessary.
 603      */
 604     static void writeDefaultJFIF(ImageOutputStream ios,
 605                                  List<? extends BufferedImage> thumbnails,
 606                                  ICC_Profile iccProfile,
 607                                  JPEGImageWriter writer)
 608         throws IOException {
 609 
 610         JFIFMarkerSegment jfif = new JFIFMarkerSegment();
 611         jfif.writeWithThumbs(ios, thumbnails, writer);
 612         if (iccProfile != null) {
 613             writeICC(iccProfile, ios);
 614         }
 615     }
 616 
 617     /**
 618      * Prints out the contents of this object to System.out for debugging.
 619      */
 620     void print() {




  73     int resUnits;
  74     int Xdensity;
  75     int Ydensity;
  76     int thumbWidth;
  77     int thumbHeight;
  78     JFIFThumbRGB thumb = null;  // If present
  79     ArrayList<JFIFExtensionMarkerSegment> extSegments = new ArrayList<>();
  80     ICCMarkerSegment iccSegment = null; // optional ICC
  81     private static final int THUMB_JPEG = 0x10;
  82     private static final int THUMB_PALETTE = 0x11;
  83     private static final int THUMB_UNASSIGNED = 0x12;
  84     private static final int THUMB_RGB = 0x13;
  85     private static final int DATA_SIZE = 14;
  86     private static final int ID_SIZE = 5;
  87     private final int MAX_THUMB_WIDTH = 255;
  88     private final int MAX_THUMB_HEIGHT = 255;
  89 
  90     private final boolean debug = false;
  91 
  92     /**
  93      * Set to {@code true} when reading the chunks of an
  94      * ICC profile.  All chunks are consolidated to create a single
  95      * "segment" containing all the chunks.  This flag is a state
  96      * variable identifying whether to construct a new segment or
  97      * append to an old one.
  98      */
  99     private boolean inICC = false;
 100 
 101     /**
 102      * A placeholder for an ICC profile marker segment under
 103      * construction.  The segment is not added to the list
 104      * until all chunks have been read.
 105      */
 106     private ICCMarkerSegment tempICCSegment = null;
 107 
 108 
 109     /**
 110      * Default constructor.  Used to create a default JFIF header
 111      */
 112     JFIFMarkerSegment() {
 113         super(JPEG.APP0);


 577         jfxx.write(ios, writer);
 578         writer.thumbnailComplete();
 579     }
 580 
 581 
 582     /**
 583      * Return an RGB image that is the expansion of the given grayscale
 584      * image.
 585      */
 586     private static BufferedImage expandGrayThumb(BufferedImage thumb) {
 587         BufferedImage ret = new BufferedImage(thumb.getWidth(),
 588                                               thumb.getHeight(),
 589                                               BufferedImage.TYPE_INT_RGB);
 590         Graphics g = ret.getGraphics();
 591         g.drawImage(thumb, 0, 0, null);
 592         return ret;
 593     }
 594 
 595     /**
 596      * Writes out a default JFIF marker segment to the given
 597      * output stream.  If {@code thumbnails} is not {@code null},
 598      * writes out the set of thumbnail images as JFXX marker segments, or
 599      * incorporated into the JFIF segment if appropriate.
 600      * If {@code iccProfile} is not {@code null},
 601      * writes out the profile after the JFIF segment using as many APP2
 602      * marker segments as necessary.
 603      */
 604     static void writeDefaultJFIF(ImageOutputStream ios,
 605                                  List<? extends BufferedImage> thumbnails,
 606                                  ICC_Profile iccProfile,
 607                                  JPEGImageWriter writer)
 608         throws IOException {
 609 
 610         JFIFMarkerSegment jfif = new JFIFMarkerSegment();
 611         jfif.writeWithThumbs(ios, thumbnails, writer);
 612         if (iccProfile != null) {
 613             writeICC(iccProfile, ios);
 614         }
 615     }
 616 
 617     /**
 618      * Prints out the contents of this object to System.out for debugging.
 619      */
 620     void print() {


< prev index next >