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; }
/** * Creates a ROIDeScaler object. The information needed to create the * object is the Entropy decoder used and the parameters. * * @param src The source of data that is to be descaled * * @param pl The parameter list (or options). * * @param decSpec The decoding specifications * * @exception IllegalArgumentException If an error occurs while parsing * the options in 'pl' * */ public static ROIDeScaler createInstance(CBlkQuantDataSrcDec src, J2KImageReadParamJava j2krparam, DecoderSpecs decSpec){ // Check if no_roi specified in command line or no roi signalled // in bit stream boolean noRoi = j2krparam.getNoROIDescaling(); if (noRoi || decSpec.rois == null) { // no_roi specified in commandline! return new ROIDeScaler(src,null); } return new ROIDeScaler(src, decSpec.rois ); } }
this.height = hd.getImgHeight(); Rectangle sourceRegion = param.getSourceRegion(); sourceOrigin = new Point(); sourceRegion = param.getResolution() : minResLevels; if(resolution < 0 || resolution > minResLevels) { resolution = minResLevels; this.width, this.height, param.getDestination(), sourceRegion, destinationRegion); scaleX = param.getSourceXSubsampling(); scaleY = param.getSourceYSubsampling(); xOffset = param.getSubsamplingXOffset(); yOffset = param.getSubsamplingYOffset(); sourceBands = j2krparam.getSourceBands(); destinationBands = j2krparam.getDestinationBands(); if (destinationBands == null) { destinationBands = new int[nComp];
if (j2krparam.getDecodingRate() == Double.MAX_VALUE) tnbytes = Integer.MAX_VALUE; else tnbytes = (int)(j2krparam.getDecodingRate() * hd.getMaxCompImgWidth() * hd.getMaxCompImgHeight()) / 8; if(j2krparam.getResolution()== -1) { targetRes = decSpec.dls.getMin(); } else { targetRes = j2krparam.getResolution(); if(targetRes<0) { throw new
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(); }
private void clipDestination(Rectangle dest) { Point offset = j2krparam.getDestinationOffset(); if (dest.x < offset.x) { dest.width += dest.x - offset.x; dest.x = offset.x ; } if (dest.y < offset.y) { dest.height += dest.y - offset.y; dest.y = offset.y ; } } }
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 RenderedImage readAsRenderedImage(int imageIndex, ImageReadParam param) throws IOException { checkIndex(imageIndex); RenderedImage ri = null; clearAbortRequest(); processImageStarted(imageIndex); if (param == null) param = getDefaultReadParam(); param = new J2KImageReadParamJava(param); if (!ignoreMetadata) { if (imageMetadata == null) imageMetadata = new J2KMetadata(); ri = new J2KRenderedImage(iis, (J2KImageReadParamJava)param, imageMetadata, this); } else ri = new J2KRenderedImage(iis, (J2KImageReadParamJava)param, this); if (abortRequested()) processReadAborted(); else processImageComplete(); return ri; }
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; }