use of javax.imageio.ImageTypeSpecifier in project jdk8u_jdk by JetBrains.
the class WBMPImageReader method getImageTypes.
public Iterator getImageTypes(int imageIndex) throws IOException {
checkIndex(imageIndex);
readHeader();
BufferedImage bi = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_BINARY);
ArrayList list = new ArrayList(1);
list.add(new ImageTypeSpecifier(bi));
return list.iterator();
}
use of javax.imageio.ImageTypeSpecifier in project jdk8u_jdk by JetBrains.
the class PNGImageReader method getRawImageType.
/*
* Super class implementation uses first element
* of image types list as raw image type.
*
* Also, super implementation uses first element of this list
* as default destination type image read param does not specify
* anything other.
*
* However, in case of RGB and RGBA color types, raw image type
* produces buffered image of custom type. It causes some
* performance degradation of subsequent rendering operations.
*
* To resolve this contradiction we put standard image types
* at the first positions of image types list (to produce standard
* images by default) and put raw image type (which is custom)
* at the last position of this list.
*
* After this changes we should override getRawImageType()
* to return last element of image types list.
*/
public ImageTypeSpecifier getRawImageType(int imageIndex) throws IOException {
Iterator<ImageTypeSpecifier> types = getImageTypes(imageIndex);
ImageTypeSpecifier raw = null;
do {
raw = types.next();
} while (types.hasNext());
return raw;
}
use of javax.imageio.ImageTypeSpecifier in project jdk8u_jdk by JetBrains.
the class BMPImageReader method readEmbedded.
/** Decodes the jpeg/png image embedded in the bitmap using any jpeg
* ImageIO-style plugin.
*
* @param bi The destination <code>BufferedImage</code>.
* @param bmpParam The <code>ImageReadParam</code> for decoding this
* BMP image. The parameters for subregion, band selection and
* subsampling are used in decoding the jpeg image.
*/
private BufferedImage readEmbedded(int type, BufferedImage bi, ImageReadParam bmpParam) throws IOException {
String format;
switch(type) {
case BI_JPEG:
format = "JPEG";
break;
case BI_PNG:
format = "PNG";
break;
default:
throw new IOException("Unexpected compression type: " + type);
}
ImageReader reader = ImageIO.getImageReadersByFormatName(format).next();
if (reader == null) {
throw new RuntimeException(I18N.getString("BMPImageReader4") + " " + format);
}
// prepare input
byte[] buff = new byte[(int) imageSize];
iis.read(buff);
reader.setInput(ImageIO.createImageInputStream(new ByteArrayInputStream(buff)));
if (bi == null) {
ImageTypeSpecifier embType = reader.getImageTypes(0).next();
bi = embType.createBufferedImage(destinationRegion.x + destinationRegion.width, destinationRegion.y + destinationRegion.height);
}
reader.addIIOReadProgressListener(new EmbeddedProgressAdapter() {
public void imageProgress(ImageReader source, float percentageDone) {
processImageProgress(percentageDone);
}
});
reader.addIIOReadUpdateListener(new IIOReadUpdateListener() {
public void imageUpdate(ImageReader source, BufferedImage theImage, int minX, int minY, int width, int height, int periodX, int periodY, int[] bands) {
processImageUpdate(theImage, minX, minY, width, height, periodX, periodY, bands);
}
public void passComplete(ImageReader source, BufferedImage theImage) {
processPassComplete(theImage);
}
public void passStarted(ImageReader source, BufferedImage theImage, int pass, int minPass, int maxPass, int minX, int minY, int periodX, int periodY, int[] bands) {
processPassStarted(theImage, pass, minPass, maxPass, minX, minY, periodX, periodY, bands);
}
public void thumbnailPassComplete(ImageReader source, BufferedImage thumb) {
}
public void thumbnailPassStarted(ImageReader source, BufferedImage thumb, int pass, int minPass, int maxPass, int minX, int minY, int periodX, int periodY, int[] bands) {
}
public void thumbnailUpdate(ImageReader source, BufferedImage theThumbnail, int minX, int minY, int width, int height, int periodX, int periodY, int[] bands) {
}
});
reader.addIIOReadWarningListener(new IIOReadWarningListener() {
public void warningOccurred(ImageReader source, String warning) {
processWarningOccurred(warning);
}
});
ImageReadParam param = reader.getDefaultReadParam();
param.setDestination(bi);
param.setDestinationBands(bmpParam.getDestinationBands());
param.setDestinationOffset(bmpParam.getDestinationOffset());
param.setSourceBands(bmpParam.getSourceBands());
param.setSourceRegion(bmpParam.getSourceRegion());
param.setSourceSubsampling(bmpParam.getSourceXSubsampling(), bmpParam.getSourceYSubsampling(), bmpParam.getSubsamplingXOffset(), bmpParam.getSubsamplingYOffset());
reader.read(0, param);
return bi;
}
use of javax.imageio.ImageTypeSpecifier in project jdk8u_jdk by JetBrains.
the class ImageUtil method canEncodeImage.
/** Checks that the provided <code>ImageWriter</code> can encode
* the provided <code>ColorModel</code> and <code>SampleModel</code>.
* If not, an <code>IIOException</code> will be thrown.
* @param writer The provided <code>ImageWriter</code>.
* @param colorModel The provided <code>ColorModel</code>.
* @param sampleModel The provided <code>SampleModel</code>.
* @throws IIOException If the writer cannot encoded the provided image.
*/
public static final void canEncodeImage(ImageWriter writer, ColorModel colorModel, SampleModel sampleModel) throws IIOException {
ImageTypeSpecifier type = null;
if (colorModel != null && sampleModel != null)
type = new ImageTypeSpecifier(colorModel, sampleModel);
canEncodeImage(writer, type);
}
use of javax.imageio.ImageTypeSpecifier in project jdk8u_jdk by JetBrains.
the class BMPImageReader method getImageTypes.
public Iterator getImageTypes(int imageIndex) throws IOException {
checkIndex(imageIndex);
try {
readHeader();
} catch (IllegalArgumentException e) {
throw new IIOException(I18N.getString("BMPImageReader6"), e);
}
ArrayList list = new ArrayList(1);
list.add(new ImageTypeSpecifier(originalColorModel, originalSampleModel));
return list.iterator();
}
Aggregations