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

Print this page


   1 /*
   2  * Copyright (c) 2001, 2011, 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


1431                 chunks.add(profileData);
1432                 chunksRead = 1;
1433                 inICC = true;
1434             }
1435         }
1436 
1437         ICCMarkerSegment(Node node) throws IIOInvalidTreeException {
1438             super(JPEG.APP2);
1439             if (node instanceof IIOMetadataNode) {
1440                 IIOMetadataNode ourNode = (IIOMetadataNode) node;
1441                 ICC_Profile prof = (ICC_Profile) ourNode.getUserObject();
1442                 if (prof != null) {  // May be null
1443                     profile = prof.getData();
1444                 }
1445             }
1446         }
1447 
1448         protected Object clone () {
1449             ICCMarkerSegment newGuy = (ICCMarkerSegment) super.clone();
1450             if (profile != null) {
1451                 newGuy.profile = (byte[]) profile.clone();
1452             }
1453             return newGuy;
1454         }
1455 
1456         boolean addData(JPEGBuffer buffer) throws IOException {
1457             if (debug) {
1458                 System.out.println("Adding to ICC segment");
1459             }
1460             // skip the tag
1461             buffer.bufPtr++;
1462             buffer.bufAvail--;
1463             // Get the length, but not in length
1464             int dataLen = (buffer.buf[buffer.bufPtr++] & 0xff) << 8;
1465             dataLen |= buffer.buf[buffer.bufPtr++] & 0xff;
1466             buffer.bufAvail -= 2;
1467             // Don't include length itself
1468             dataLen -= 2;
1469             // skip the id
1470             buffer.bufPtr += ID_SIZE; // Skip the id
1471             buffer.bufAvail -= ID_SIZE;


   1 /*
   2  * Copyright (c) 2001, 2014, 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


1431                 chunks.add(profileData);
1432                 chunksRead = 1;
1433                 inICC = true;
1434             }
1435         }
1436 
1437         ICCMarkerSegment(Node node) throws IIOInvalidTreeException {
1438             super(JPEG.APP2);
1439             if (node instanceof IIOMetadataNode) {
1440                 IIOMetadataNode ourNode = (IIOMetadataNode) node;
1441                 ICC_Profile prof = (ICC_Profile) ourNode.getUserObject();
1442                 if (prof != null) {  // May be null
1443                     profile = prof.getData();
1444                 }
1445             }
1446         }
1447 
1448         protected Object clone () {
1449             ICCMarkerSegment newGuy = (ICCMarkerSegment) super.clone();
1450             if (profile != null) {
1451                 newGuy.profile = profile.clone();
1452             }
1453             return newGuy;
1454         }
1455 
1456         boolean addData(JPEGBuffer buffer) throws IOException {
1457             if (debug) {
1458                 System.out.println("Adding to ICC segment");
1459             }
1460             // skip the tag
1461             buffer.bufPtr++;
1462             buffer.bufAvail--;
1463             // Get the length, but not in length
1464             int dataLen = (buffer.buf[buffer.bufPtr++] & 0xff) << 8;
1465             dataLen |= buffer.buf[buffer.bufPtr++] & 0xff;
1466             buffer.bufAvail -= 2;
1467             // Don't include length itself
1468             dataLen -= 2;
1469             // skip the id
1470             buffer.bufPtr += ID_SIZE; // Skip the id
1471             buffer.bufAvail -= ID_SIZE;