public J2KRenderedImage(ImageInputStream iis, J2KImageReadParamJava param, J2KImageReader reader) throws IOException { this(new J2KReadState(iis, param, reader)); }
public J2KRenderedImage(J2KReadState readState) { this.readState = readState; HeaderDecoder hd = readState.getHeader(); //determnined by destination Rectangle destinationRegion = readState.getDestinationRegion(); width = destinationRegion.width; height = destinationRegion.height; minX = destinationRegion.x; minY = destinationRegion.y; Rectangle tile0Rect = readState.getTile0Rect(); tileWidth = tile0Rect.width; tileHeight = tile0Rect.height; tileGridXOffset = tile0Rect.x; tileGridYOffset = tile0Rect.y; sampleModel = readState.getSampleModel(); colorModel = readState.getColorModel(); }
public ImageTypeSpecifier getImageType() throws IOException { getSampleModel(); getColorModel(); return new ImageTypeSpecifier(colorModel, sampleModel); }
public BufferedImage readBufferedImage() throws IOException { colorModel = getColorModel(); sampleModel = getSampleModel(); WritableRaster raster = null; BufferedImage image = j2krparam.getDestination(); int x = destinationRegion.x; int y = destinationRegion.y; destinationRegion.setLocation(j2krparam.getDestinationOffset()); if (image == null) { // If the destination type is specified, use the color model of it. ImageTypeSpecifier type = j2krparam.getDestinationType(); if (type != null) colorModel = type.getColorModel(); raster = Raster.createWritableRaster( sampleModel.createCompatibleSampleModel(destinationRegion.x + destinationRegion.width, destinationRegion.y + destinationRegion.height), new Point(0, 0)); image = new BufferedImage(colorModel, raster, colorModel.isAlphaPremultiplied(), new Hashtable()); } else raster = image.getWritableTile(0, 0); destImage = image; readSubsampledRaster(raster); destinationRegion.setLocation(x, y); destImage = null; return image; }
public Raster readAsRaster() throws IOException { BufferedImage image = j2krparam.getDestination(); WritableRaster raster = null; if (image == null) { sampleModel = getSampleModel(); raster = Raster.createWritableRaster( sampleModel.createCompatibleSampleModel(destinationRegion.x + destinationRegion.width, destinationRegion.y + destinationRegion.height), new Point(0, 0)); } else raster = image.getWritableTile(0, 0); readSubsampledRaster(raster); return raster; }
public void readHeader() { if (gotHeader) return; if (readState == null) { try { iis.seek(streamPosition0); } catch(IOException e) { // XXX ignore } readState = new J2KReadState(iis, new J2KImageReadParamJava(getDefaultReadParam()), this); } hd = readState.getHeader(); gotHeader = true; this.width = hd.getImgWidth(); this.height = hd.getImgHeight(); }
public Raster readRaster(int imageIndex, ImageReadParam param) throws IOException { checkIndex(imageIndex); processImageStarted(imageIndex); if (param == null) { param = getDefaultReadParam(); } param = new J2KImageReadParamJava(param); if (!ignoreMetadata) { imageMetadata = new J2KMetadata(); iis.seek(streamPosition0); readState = new J2KReadState(iis, (J2KImageReadParamJava)param, imageMetadata, this); } else { iis.seek(streamPosition0); readState = new J2KReadState(iis, (J2KImageReadParamJava)param, this); } Raster ras = readState.readAsRaster(); if (abortRequested()) processReadAborted(); else processImageComplete(); return ras; }
public BufferedImage read(int imageIndex, ImageReadParam param) throws IOException { checkIndex(imageIndex); clearAbortRequest(); processImageStarted(imageIndex); if (param == null) param = getDefaultReadParam(); param = new J2KImageReadParamJava(param); if (!ignoreMetadata) { imageMetadata = new J2KMetadata(); iis.seek(streamPosition0); readState = new J2KReadState(iis, (J2KImageReadParamJava)param, imageMetadata, this); } else { iis.seek(streamPosition0); readState = new J2KReadState(iis, (J2KImageReadParamJava)param, this); } BufferedImage bi = readState.readBufferedImage(); if (abortRequested()) processReadAborted(); else processImageComplete(); return bi; }
/** Constructs <code>J2KReadState</code>. * @param iis The input stream. * @param param The reading parameters. * @param reader The <code>J2KImageReader</code> which holds this state. * It is necessary for processing abortion. * @throw IllegalArgumentException If the provided <code>iis</code>, * or <code>param</code> is <code>null</code>. */ public J2KReadState(ImageInputStream iis, J2KImageReadParamJava param, J2KImageReader reader) { if (iis == null || param == null) throw new IllegalArgumentException(I18N.getString("J2KReadState0")); this.iis = iis; this.j2krparam = param; this.reader = reader; initializeRead(0, param, null); }
Raster.createWritableRaster(sampleModel, new Point(x, y)); currentTile = readState.getTile(tileX, tileY, (WritableRaster)currentTile);
if(hi.siz.csiz == 1 && (maxBitDepth == 1 || maxBitDepth == 2 || maxBitDepth == 4)) { colorModel = ImageUtil.createColorModel(getSampleModel()); } else { colorModel = new ComponentColorModel(cs, sampleModel = getSampleModel();
public Iterator getImageTypes(int imageIndex) throws IOException { checkIndex(imageIndex); readHeader(); if (readState != null) { ArrayList list = new ArrayList(); list.add(new ImageTypeSpecifier(readState.getColorModel(), readState.getSampleModel())); return list.iterator(); } return null; }
/** Constructs <code>J2KReadState</code>. * @param iis The input stream. * @param param The reading parameters. * @param metadata The <code>J2KMetadata</code> to cache the metadata read * from the input stream. * @param reader The <code>J2KImageReader</code> which holds this state. * It is necessary for processing abortion. * @throw IllegalArgumentException If the provided <code>iis</code>, * <code>param</code> or <code>metadata</code> is <code>null</code>. */ public J2KReadState(ImageInputStream iis, J2KImageReadParamJava param, J2KMetadata metadata, J2KImageReader reader) { if (iis == null || param == null || metadata == null) throw new IllegalArgumentException(I18N.getString("J2KReadState0")); this.iis = iis; this.j2krparam = param; this.metadata = metadata; this.reader = reader; initializeRead(0, param, metadata); }
private ImageTypeSpecifier getImageType(int imageIndex) throws IOException { checkIndex(imageIndex); readHeader(); if (readState != null) { return new ImageTypeSpecifier(readState.getColorModel(), readState.getSampleModel()); } return null; }
public J2KRenderedImage(ImageInputStream iis, J2KImageReadParamJava param, J2KMetadata metadata, J2KImageReader reader) throws IOException { this(new J2KReadState(iis, param, metadata, reader)); }