src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java

Print this page
rev 9343 : 8033716: Fix raw and unchecked lint warnings in com.sun.imageio
Reviewed-by: darcy, prr, bae

*** 70,80 **** GIFImageMetadata imageMetadata = null; // A List of Longs indicating the stream positions of the // start of the metadata for each image. Entries are added // as needed. ! List imageStartPosition = new ArrayList(); // Length of metadata for image at 'currIndex', valid only if // imageMetadata != null. int imageMetadataLength; --- 70,80 ---- GIFImageMetadata imageMetadata = null; // A List of Longs indicating the stream positions of the // start of the metadata for each image. Entries are added // as needed. ! List<Long> imageStartPosition = new ArrayList<>(); // Length of metadata for image at 'currIndex', valid only if // imageMetadata != null. int imageMetadataLength;
*** 225,244 **** 1, 1, bits); } return new ImageTypeSpecifier(colorModel, sampleModel); } ! public Iterator getImageTypes(int imageIndex) throws IIOException { checkIndex(imageIndex); int index = locateImage(imageIndex); if (index != imageIndex) { throw new IndexOutOfBoundsException(); } readMetadata(); ! List l = new ArrayList(1); byte[] colorTable; if (imageMetadata.localColorTable != null) { colorTable = imageMetadata.localColorTable; fallbackColorTable = imageMetadata.localColorTable; --- 225,245 ---- 1, 1, bits); } return new ImageTypeSpecifier(colorModel, sampleModel); } ! public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) ! throws IIOException { checkIndex(imageIndex); int index = locateImage(imageIndex); if (index != imageIndex) { throw new IndexOutOfBoundsException(); } readMetadata(); ! List<ImageTypeSpecifier> l = new ArrayList<>(1); byte[] colorTable; if (imageMetadata.localColorTable != null) { colorTable = imageMetadata.localColorTable; fallbackColorTable = imageMetadata.localColorTable;
*** 603,613 **** try { // Find closest known index int index = Math.min(imageIndex, imageStartPosition.size() - 1); // Seek to that position ! Long l = (Long)imageStartPosition.get(index); stream.seek(l.longValue()); // Skip images until at desired index or last image found while (index < imageIndex) { if (!skipImage()) { --- 604,614 ---- try { // Find closest known index int index = Math.min(imageIndex, imageStartPosition.size() - 1); // Seek to that position ! Long l = imageStartPosition.get(index); stream.seek(l.longValue()); // Skip images until at desired index or last image found while (index < imageIndex) { if (!skipImage()) {
*** 729,739 **** stream.readUnsignedByte(); imageMetadata.text = concatenateBlocks(); } else if (label == 0xfe) { // Comment extension byte[] comment = concatenateBlocks(); if (imageMetadata.comments == null) { ! imageMetadata.comments = new ArrayList(); } imageMetadata.comments.add(comment); } else if (label == 0xff) { // Application extension int blockSize = stream.readUnsignedByte(); byte[] applicationID = new byte[8]; --- 730,740 ---- stream.readUnsignedByte(); imageMetadata.text = concatenateBlocks(); } else if (label == 0xfe) { // Comment extension byte[] comment = concatenateBlocks(); if (imageMetadata.comments == null) { ! imageMetadata.comments = new ArrayList<>(); } imageMetadata.comments.add(comment); } else if (label == 0xff) { // Application extension int blockSize = stream.readUnsignedByte(); byte[] applicationID = new byte[8];
*** 760,773 **** applicationData = data; } // Init lists if necessary if (imageMetadata.applicationIDs == null) { ! imageMetadata.applicationIDs = new ArrayList(); imageMetadata.authenticationCodes = ! new ArrayList(); ! imageMetadata.applicationData = new ArrayList(); } imageMetadata.applicationIDs.add(applicationID); imageMetadata.authenticationCodes.add(authCode); imageMetadata.applicationData.add(applicationData); } else { --- 761,774 ---- applicationData = data; } // Init lists if necessary if (imageMetadata.applicationIDs == null) { ! imageMetadata.applicationIDs = new ArrayList<>(); imageMetadata.authenticationCodes = ! new ArrayList<>(); ! imageMetadata.applicationData = new ArrayList<>(); } imageMetadata.applicationIDs.add(applicationID); imageMetadata.authenticationCodes.add(authCode); imageMetadata.applicationData.add(applicationData); } else {
*** 866,876 **** if (param == null) { param = getDefaultReadParam(); } // Initialize the destination image ! Iterator imageTypes = getImageTypes(imageIndex); this.theImage = getDestination(param, imageTypes, imageMetadata.imageWidth, imageMetadata.imageHeight); this.theTile = theImage.getWritableTile(0, 0); --- 867,877 ---- if (param == null) { param = getDefaultReadParam(); } // Initialize the destination image ! Iterator<ImageTypeSpecifier> imageTypes = getImageTypes(imageIndex); this.theImage = getDestination(param, imageTypes, imageMetadata.imageWidth, imageMetadata.imageHeight); this.theTile = theImage.getWritableTile(0, 0);
*** 1029,1039 **** private void resetStreamSettings() { gotHeader = false; streamMetadata = null; currIndex = -1; imageMetadata = null; ! imageStartPosition = new ArrayList(); numImages = -1; // No need to reinitialize 'block' blockLength = 0; bitPos = 0; --- 1030,1040 ---- private void resetStreamSettings() { gotHeader = false; streamMetadata = null; currIndex = -1; imageMetadata = null; ! imageStartPosition = new ArrayList<>(); numImages = -1; // No need to reinitialize 'block' blockLength = 0; bitPos = 0;