Documentation Contents

Image I/O Enhancements in Java SE 6.0

Major Features
Fixed Bugs

Major Features

A writer plug-in for the GIF file format

While reading capabilities for the GIF file format have been available since Java SE 1.4, the com.sun.media.imageio.plugins.gif package lacked a writer. The newly added GIF image writer enables writing images which satisfy the following requirements:

Additionally, the GIF images writer supports the animated GIF images creation through the standard methods defined in the ImageWriter class. See more details about the GIF images writer in the Standard plug-in for GIF image format notes.

New methods for file formats filtering

Two new methods were introduced in the ImageIO class that obtain file suffixes to be filtered. The getReaderFileSuffixes() and getWriterFileSuffixes methods return an array of Strings listing all of the file suffixes associated with the formats recognized by the current set of registered readers and writers.

Fixed Bugs

API and doc changes

4953566 The mark() or reset() methods of the ImageInputStream class do not work properly with PNG ImageReader:

The following note was added to the ImageInputStream class specification to clarify that ImageReader classes are allowed to call the flushBefore() as part of the decoding process:

Note that it is valid for an ImageReader to call flushBefore as part of a read operation. Therefore, if an application calls the mark prior to passing that stream to an ImageReader, the application should not assume that the marked position will remain valid after the read operation has completed.

5068322 The javax.imageio.plugins.jpeg.JPEGQTable.toString() method produces incorrect description:

The toString() method of the JPEGQTable class in the package javax.imageio.plugins.jpeg was supposed to return a String object containing the values of the table, but instead repeated only the first line of the table. The performed fix eliminate this error.

6359957 Wrong doc URL reference for PNG specification:

The link to the PNG specification in the javax.imageio.metadata package was corrected to the following URL:

http://www.libpng.org/pub/png/spec/

6457035 javadoc for ImageInputStreamImpl.read() method is missing:

The ImageInputStreamImpl.java file had a missing '*' character at the beginning of the javadoc for the abstract read() method definition.The fix fills in the missing character.

BMP plugin improvements

6294920 The BMPImageReader class fails to read 3BYTE_BGR images encoded using BMP Writer with BI_JPEG compression:

While attempting to write an image of the BI_JPEG compression type, the java.io.EOFException was thrown by the BMPImageReader class. The problem was that the BMPImageReader class did not process embedded images both of BI_JPEG and BI_PNG types. To resolve this problem, the embedded image handling is moved to separate code.

6297016 Output BMP image is distorted when writing TYPE_3BYTE_BGR buffered image with BI_BITFIELDS compression:

While attempting to write a buffered image of the TYPE_3BYTE_BGR type to a file using the BMPWriter class and the BI_BITFIELDS compression type, the output image was distorted and unusable. This problem was caused by the bitfileds masks which were applied to a bmp image. However, an image data layout was not changed according to the BMP format requirements. To fix this problem the writePixels() method is used to copy image data correctly.

5076878 ImageIO BMP Writer writes 32 bit files for 24 bit images:

The ImageIO.write method presented a BMP file as a 32 bit image even if the source image had 24 bits per pixel presentation. The fix enables the writePixels procedure whenever the number of bits per pixel is smaller than the size of a databuffer type (for example, with TYPE_INT_RGB, the actual number of bits per pixel is 24 while the size of the databuffer type is 32).

6332480 The BMPReader class fails to read the TYPE_BYTE_GRAY image encoded by the BMPWriter class with BI_RLE8 compression:

The BMPReader class did not properly read the TYPE_BYTE_GRAY image written with the BMPWriter class using the BI_RLE8 compression. The problem was that the RLE decoding procedures (both RLE4 and RLE8) mistakenly used the width of the destination region instead of the height to calculate the range of image lines for copying. The performed fix uses the height of the destination region to calculate the range.

6399660 Using subsampling with compression alters the colors for some of the image types for BMP:

While using all the supported compression types for BMP, different affects on image were detected including blurring, a different color appearance, and slight image corruption. The performed fix separates processing BI_RGB compression and BI_RGB compression as follows:

Performance and resource management

6299405 The ImageInputStreamImpl class still uses the finalize() method which causes the java.lang.OutOfMemoryError:

The finalize() method had to be emptied and its functionality (closing the stream) must be replaced with a more prompt mechanism. The finalize() method cannot be easily emptied at the ImageInputStreamImpl level, since third-party IISI subclasses may rely on the finalize() method calling their close() method as per the spec. However, for ImageInputStreamImpl subclasses under Oracle control, the finalize() methods can be emptied. The Java2D Disposer mechanism is used instead.

6266748 The JPEGImageWriter.write() method makes a copy of the raster:

The write() method of the JPEGImageWriter class contained memory-inefficient code. The suggested fix helps to improve performance for simple rendered images.

6336804 The javax.imageio.ImageIO class can handle leaks in some methods:

Some of the read() and write() convenience methods in the javax.imageio.ImageIO class did not properly close streams and dispose reader or writer instances in a try and finally blocks. As a fix the appropriate notes were added to each method's javadocs indicating whether it is the caller's responsibility to close the provided stream or not.

6347575 FileImageInputStream.readInt() and similar methods are inefficient:

Calling the read() method of the FileImageInputStream 4x was much more expensive than making a single call to the read(byte[]) method with a cached byte array. This fact had a profound impact on performance of reading small PNG and other images. The fixes were performed for the readShort() and readInt() methods of the ImageInputStreamImpl class.

6348744 The PNGImageReader class should skip metadata if the ignoreMetadata flag has the true value:

Before JDK 6, the PNGImageReader class read all image metadata, even if the ignoreMetadata flag was set. The fix reduces overhead and improves performance when reading small PNG images by skipping metadata blocks if the ignoreMetadata flag is true.

6354056 The JPEGImageReader class could be optimized:

The JPEG image reader copied decoded data into memory, but not in an optimized way. The performed fix improves this operation by using the memcpy() method instead of copying one byte at a time.

6354112 Increase compiler optimization level for libjpeg to improve runtime performance:

The libjpeg library in the JDK was built with default compiler optimization flags. The values of these flags are increased to a higher level to enable the native IJG JPEG libraries to run faster.

6404011 IllegalArgumentException: "Invalid ICC Profile Data" when reading a certain JPEG image:

This bug was an unchecked exception and could cause a system crash on some platforms. The fix catches the IllegalArgumentException, which is thrown by ICC_Profile, and handles images without taking into account invalid color profiles.

Robustness

6291034 The IFileCacheImageInputStream and FileCacheImageOutputStream should avoid using the File.deleteOnExit method:

Both the FileCacheImageInputStream and FileCacheImageOutputStream classes used the functionality of the deleteOnExit method of the File class. The fix has replaced the File.deleteOnExit() functionality with the shutdown hook that closes streams that are still open before the VM shutdown.

4892630 The ImageReader class does not validate the image index which is passed to some of the methods:

The getWidth(imgIndex), getHeight(imgIndex), and getAspectRatio(imgIndex) methods of the ImageReader class did not throw the IndexOutOfBoundsException if the given PNG image index was out of range. The performed fix resolves this issue by throwing the exception appropriately.

4895547 JPEGImageMetadata obtained from reader throws NullPointerException when calling the mergeTree() method:

The list of parent attributes did not contain attributes related to the child node and this fact caused the NullPointerException in the MarkerSegment.getAttributeValue() method while trying to get child related attribute. The performed fix obtains the attribute list from the child node.

4528643 Native JPEG code makes JNI calls in scope of GetPrimitiveArrayCritical:

Running any application that reads or writes JPEG images with the non-standard -Xcheck:jni flag caused the following error in several methods of the JPEGImageReader class:

Calling other JNI functions in the scope of Get/ReleasePrimitiveArrayCritical or Get/ReleaseStringCritical

In the fix, the affected methods are surrounded with the RELEASE/GET_ARRAYS macros. 

5076692 Installed Extensions Image I/O reader-writer plug-ins unusable in applet context:

The problem was that the imageio registry initialization code did not have read access to jars in the java.ext.dirs when the registry code was called from applet context. Therefore, the imageio plugins installed to java.ext.dirs were not available in case of applets. The fix idea is to register plugins from java.ext.dirs in the privileged action block.

6342404 The ImageIO plugin failure causes all readers to fail:

Removing an ImageIO plugin's code from the classpath, but still including an entry for the plugin's ImageReader in META-INF/services made using any of the ImageIO plugins impossible. To fix this bug, a 'try and catch' block was added to the IIORegistry.registerApplicationClasspathSpis() method to catch the ServiceConfigurationError.

6395551 Setting the destination type to type specifier returned by redr.getImageTypes() throws exception for JPG:

The problem was that a new ColorSpace instance was re-created for embedded color profiles whenever an image header was read. In addition, there was no means for correct comparison of ColorSpace and ICC_Profile classes. This omission made comparing instances of ImageTypeSpecifier class impossible. The proposed workaround for this problem is as follows: to detect the case when the iccCS instance contains the same profile data as a newly read. If so, the 'old' instance is left; otherwise (if the profile data seems to be different) a new color space instance is created for the embedded color profile.

6399616 PIT: JPGReader throws an exception when using the TYPE_CUSTOM TypeSpecifier returned by the Reader.getImageTypes method:

The regression was caused by the fix for 4705399, where color conversion was removed (JPEGImageReader.java lines 783 -786) because it caused extra color conversion for images with embedded color profiles. However, this conversion was required when the destination type defined different color spaces for images that do not contain embedded profiles. The fix for this case converts image data from sRGB (produced by the decoder) to the color space used in the destination image.

Quality

5028259 Setting the destination image type for jpeg images increases the size of the result file:

If the write parameter with the destination type was used explicitly to write a jpeg image, then the size of the result file was bigger than if the same destination type was used implicitly. The problem was revealed when the destination type was specified but the corresponding metadata object was not specified. The fix creates the metadata object using the given destination type in order to build a SOF marker object, which will be used to change the default values of the QtableSelectors.

4881314 ImageIO does not correctly read certain standard JPG files:

The ImageIO incorrectly reads some JPG files. The result was a red or green image that looked like a photographic negative. The fix eliminates color space conversion for EXIF images. To detect EXIF images, the check for the APP1 marker in the image header is added.

5098176 Some PNG images fail to load with the ImageIO class:

The PNGImageReader failed to create the ImageTypeSpecifier instance corresponding to the indexed PNG image if the length of the image palette in smaller than 2 bitDepth. To avoid this limitation new palette arrays of the appropriate power of 2 size were created. These arrays are padded with the last value from original arrays in order to avoid the appearance of colors that do not exist in the original palette.

6372769 The ImageIO.read method improperly decodes Nikon Jpegs:

The ImageIO jpeg reader performed extra color conversion if an image contained the embedded color profile. The bug was fixed by removing the extra color conversion operation.

Miscellaneous

4972087 Quality Desc and Quality Values arrays are of the same length for JPG:

The JPEGImageWriteParam class was updated so that the getCompressionQualityValues() method returns an array whose length is one larger than the array returned by getCompressionQualityDescriptions(), as per the specification.

6195593 REGRESSION: The javax/imageio/IRPTest.java file fails:

The problem was caused by the fix for the bug 5039494. Starting with this fix, the ImageReader.computeRegion() method was used to calculate the destination region. In order to avoid discrepancies between calculated destination regions and destinations offset from the parameter, the destinationOffset is updated according to the calculated values.

6304433 Test bug: the regression test for the bug 6291034 fails on all platforms:

The regression test failure was caused by the creation of an output image file. This file was created after counting the existing files in the work directory and was not deleted on regression test finish. So, after regression test execution, the work directory always contained one extra file, although all temporary files were deleted upon VM exit. The solution is to use byte array input or output streams instead of file input or output streams in order to avoid creating extra files in the work directory.

6356926 PIT: The regression test javax/imageio/stream/DeleteOnExit.sh is failing:

The problem was caused by the fix for the bug 6299405. The affected code is fixed and the corresponding comment has been added.

6459309 The NoAPP0Test.java regression test failed on all platforms:

The difference in pixel values is caused by using new version of sRGB profile that was updated as part of fix for 6279846. New profile was integrated in the b92 build.

6363748 The close() method of the FileCacheImageInputStream class fails:

The problem was caused by the fix for the bug 6299405. As a part of that fix the FileCacheImageInputStream.close() method was changed so that it nulled out its reference to the cache object. To eliminate this issue the FCIIS.read() method is updated to call the checkClosed() method as it is supposed to do.

 


Oracle and/or its affiliates Copyright © 1993, 2024, Oracle and/or its affiliates. All rights reserved.
Contact Us