/** * Returns a compatible sample model. This implementation is nearly identical to default J2SE's * implementation, except that it construct a JAI color model instead of a J2SE one. */ public SampleModel createCompatibleSampleModel(final int w, final int h) { switch (transferType) { default: { return super.createCompatibleSampleModel(w, h); } case DataBuffer.TYPE_FLOAT: // fall through case DataBuffer.TYPE_DOUBLE: { final int numComponents = getNumComponents(); final int[] bandOffsets = new int[numComponents]; for (int i = 0; i < numComponents; i++) { bandOffsets[i] = i; } return new ComponentSampleModelJAI( transferType, w, h, numComponents, w * numComponents, bandOffsets); } } }
layout.setColorModel(colorModel); layout.setSampleModel( colorModel.createCompatibleSampleModel( inputWorker.getRenderedImage().getWidth(), inputWorker.getRenderedImage().getHeight()));
dataType); final SampleModel destinationSampleModel = destinationColorModel.createCompatibleSampleModel( sampleModel.getWidth(), sampleModel.getHeight()); ImageLayout layout = new ImageLayout(image);
layout2.setColorModel(ColorUtilities.GRAY_CM); layout2.setSampleModel( ColorUtilities.GRAY_CM.createCompatibleSampleModel( inputRI.getTileWidth(), inputRI.getTileHeight()));
datatype); final SampleModel destinationSampleModel = destinationColorModel.createCompatibleSampleModel( image.getWidth(), image.getHeight()); layout.setColorModel(destinationColorModel);
/** * Returns a compatible sample model. This implementation is nearly identical * to default J2SE's implementation, except that it construct a JAI color model * instead of a J2SE one. */ public SampleModel createCompatibleSampleModel(final int w, final int h) { switch (transferType) { default: { return super.createCompatibleSampleModel(w, h); } case DataBuffer.TYPE_FLOAT: // fall through case DataBuffer.TYPE_DOUBLE: { final int numComponents = getNumComponents(); final int[] bandOffsets = new int[numComponents]; for (int i=0; i<numComponents; i++) { bandOffsets[i] = i; } return new ComponentSampleModelJAI(transferType, w, h, numComponents, w*numComponents, bandOffsets); } } }
/** * Returns a compatible sample model. This implementation is nearly identical * to default J2SE's implementation, except that it construct a JAI color model * instead of a J2SE one. */ public SampleModel createCompatibleSampleModel(final int w, final int h) { switch (transferType) { default: { return super.createCompatibleSampleModel(w, h); } case DataBuffer.TYPE_FLOAT: // fall through case DataBuffer.TYPE_DOUBLE: { final int numComponents = getNumComponents(); final int[] bandOffsets = new int[numComponents]; for (int i=0; i<numComponents; i++) { bandOffsets[i] = i; } return new ComponentSampleModelJAI(transferType, w, h, numComponents, w*numComponents, bandOffsets); } } }
@Override public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) throws IOException { readHeader(); LinkedList<ImageTypeSpecifier> l = new LinkedList<ImageTypeSpecifier>(); ComponentColorModel ccm = new ComponentColorModel(// new ICC_ColorSpace(ICC_Profile.getInstance(ColorSpace.CS_GRAY)), new int[]{maxGray > 255 ? 16 : 8},// false, false, Transparency.OPAQUE,// (maxGray > 255) ? DataBuffer.TYPE_SHORT : DataBuffer.TYPE_BYTE); l.add(new ImageTypeSpecifier(ccm, ccm.createCompatibleSampleModel(width, height))); return l.iterator(); }
sm = cm.createCompatibleSampleModel(tileWidth, tileHeight); rasterReader.setTilesSize(tileWidth, tileHeight); } else { sm = cm.createCompatibleSampleModel(tileHeight, tileWidth);
@Override public BufferedImage read(int imageIndex, ImageReadParam param) throws IOException { readHeader(); if (imageIndex > 0) { throw new ArrayIndexOutOfBoundsException("imageIndex is " + imageIndex + " must be 0."); } ImageInputStream in = (ImageInputStream) getInput(); in.seek(dataOffset + imageIndex * width * height * (maxGray > 255 ? 2 : 1)); ComponentColorModel ccm = new ComponentColorModel(// new ICC_ColorSpace(ICC_Profile.getInstance(ColorSpace.CS_GRAY)), new int[]{maxGray > 255 ? 16 : 8},// false, false, Transparency.OPAQUE,// (maxGray > 255) ? DataBuffer.TYPE_SHORT : DataBuffer.TYPE_BYTE); SampleModel sm = ccm.createCompatibleSampleModel(width, height); BufferedImage img; if (maxGray > 255) { DataBufferShort db = new DataBufferShort(width * height); in.readFully(db.getData(), 0, width * height); img = new BufferedImage(ccm, Raster.createWritableRaster(sm, db, new Point(0, 0)), false, new Hashtable<Object, Object>()); } else { DataBufferByte db = new DataBufferByte(width * height); in.readFully(db.getData(), 0, width * height); img = new BufferedImage(ccm, Raster.createWritableRaster(sm, db, new Point(0, 0)), false, new Hashtable<Object, Object>()); } return img; }
@Override public SampleModel createCompatibleSampleModel(int width, int height) { // workaround -- create a MultiPixelPackedSample models for // single-sample, less than 8bpp color models if (getNumComponents() == 1 && getPixelSize() < 8) { return new MultiPixelPackedSampleModel(getTransferType(), width, height, getPixelSize()); } return super.createCompatibleSampleModel(width, height); }
@Override public SampleModel createCompatibleSampleModel(int width, int height) { // workaround -- create a MultiPixelPackedSample models for // single-sample, less than 8bpp color models if (getNumComponents() == 1 && getPixelSize() < 8) { return new MultiPixelPackedSampleModel(getTransferType(), width, height, getPixelSize()); } return super.createCompatibleSampleModel(width, height); }
alpha?Transparency.TRANSLUCENT:Transparency.OPAQUE, datatype); final SampleModel destinationSampleModel=destinationColorModel.createCompatibleSampleModel(image.getWidth(), image.getHeight()); layout.setColorModel(destinationColorModel); layout.setSampleModel(destinationSampleModel);
: Transparency.OPAQUE, datatype); final SampleModel destinationSampleModel = destinationColorModel .createCompatibleSampleModel(image.getWidth(), image.getHeight()); layout.setColorModel(destinationColorModel); layout.setSampleModel(destinationSampleModel);