< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 286                                                          param,
 287                                                          this);
 288                 try {
 289                     jpegData.setFromTree(formatName, tree);
 290                 } catch (IIOInvalidTreeException e) {
 291                     // Other plug-in generates bogus standard tree
 292                     // XXX Maybe this should put out a warning?
 293                     return null;
 294                 }
 295 
 296                 return jpegData;
 297             }
 298         }
 299         return null;
 300     }
 301 
 302     public int getNumThumbnailsSupported(ImageTypeSpecifier imageType,
 303                                          ImageWriteParam param,
 304                                          IIOMetadata streamMetadata,
 305                                          IIOMetadata imageMetadata) {








 306         if (jfifOK(imageType, param, streamMetadata, imageMetadata)) {
 307             return Integer.MAX_VALUE;
 308         }
 309         return 0;
 310     }
 311 
 312     static final Dimension [] preferredThumbSizes = {new Dimension(1, 1),
 313                                                      new Dimension(255, 255)};
 314 
 315     public Dimension[] getPreferredThumbnailSizes(ImageTypeSpecifier imageType,
 316                                                   ImageWriteParam param,
 317                                                   IIOMetadata streamMetadata,
 318                                                   IIOMetadata imageMetadata) {
 319         if (jfifOK(imageType, param, streamMetadata, imageMetadata)) {
 320             return preferredThumbSizes.clone();
 321         }
 322         return null;
 323     }
 324 
 325     private boolean jfifOK(ImageTypeSpecifier imageType,


   1 /*
   2  * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 286                                                          param,
 287                                                          this);
 288                 try {
 289                     jpegData.setFromTree(formatName, tree);
 290                 } catch (IIOInvalidTreeException e) {
 291                     // Other plug-in generates bogus standard tree
 292                     // XXX Maybe this should put out a warning?
 293                     return null;
 294                 }
 295 
 296                 return jpegData;
 297             }
 298         }
 299         return null;
 300     }
 301 
 302     public int getNumThumbnailsSupported(ImageTypeSpecifier imageType,
 303                                          ImageWriteParam param,
 304                                          IIOMetadata streamMetadata,
 305                                          IIOMetadata imageMetadata) {
 306         // Check whether sufficient data is available.
 307         if (imageType == null && imageMetadata == null) {
 308             // The method has been invoked with insufficient data. Henceforth
 309             // we return -1 as recommended by ImageWriter specification.
 310             return -1;
 311         }
 312 
 313         // Check if the image type and metadata are JFIF compatible.
 314         if (jfifOK(imageType, param, streamMetadata, imageMetadata)) {
 315             return Integer.MAX_VALUE;
 316         }
 317         return 0;
 318     }
 319 
 320     static final Dimension [] preferredThumbSizes = {new Dimension(1, 1),
 321                                                      new Dimension(255, 255)};
 322 
 323     public Dimension[] getPreferredThumbnailSizes(ImageTypeSpecifier imageType,
 324                                                   ImageWriteParam param,
 325                                                   IIOMetadata streamMetadata,
 326                                                   IIOMetadata imageMetadata) {
 327         if (jfifOK(imageType, param, streamMetadata, imageMetadata)) {
 328             return preferredThumbSizes.clone();
 329         }
 330         return null;
 331     }
 332 
 333     private boolean jfifOK(ImageTypeSpecifier imageType,


< prev index next >