當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageReadParam.setSourceSubsampling方法代碼示例

本文整理匯總了Java中javax.imageio.ImageReadParam.setSourceSubsampling方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageReadParam.setSourceSubsampling方法的具體用法?Java ImageReadParam.setSourceSubsampling怎麽用?Java ImageReadParam.setSourceSubsampling使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.imageio.ImageReadParam的用法示例。


在下文中一共展示了ImageReadParam.setSourceSubsampling方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: call

import javax.imageio.ImageReadParam; //導入方法依賴的package包/類
public BufferedImage call() throws Exception {
	ImageInputStream iis = null;
	try {
		LOGGER.debug("Loading {} @ {}", url.toString(), level);
		final ImageReader imgReader = ImageIO.getImageReadersBySuffix(suffix(url.getFile())).next();
		iis = ImageIO.createImageInputStream(url.openStream());
		imgReader.setInput(iis);
		final ImageReadParam readParam = imgReader.getDefaultReadParam();
		if (level > 0) {
			readParam.setSourceSubsampling(level, level, 0, 0);
		}
		BufferedImage img = imgReader.read(0, readParam);
		return img;
	} catch (IOException ioe) {
		LOGGER.error("Unable to load image", ioe);
		return null;
	} finally {
		if (iis != null) {
			try {
				iis.close();
			} catch (IOException e) {
				// ignore
			}
		}
		if (component != null) {
			SwingUtilities.invokeLater(new Runnable() {
				public void run() {
					component.invalidate();
					component.validate();
					component.repaint();
				}
			});
		}
	}
}
 
開發者ID:laccore,項目名稱:coretools,代碼行數:36,代碼來源:LoadTask.java

示例2: loadSubimage

import javax.imageio.ImageReadParam; //導入方法依賴的package包/類
public void loadSubimage(ImageInput ii, Rectangle region, int prescale)
	throws FileOpException {
	logger.debug("loadSubimage: "+ii.getFile());
	//System.gc();
	try {
		if ((reader == null) || (imgFile != ii.getFile())) {
			getReader(ii);
		}
		ImageReadParam readParam = reader.getDefaultReadParam();
		readParam.setSourceRegion(region);
		readParam.setSourceSubsampling(prescale, prescale, 0, 0);
		img = reader.read(0, readParam);
		/* JAI imageread seems to ignore the readParam :-(
		ImageInputStream istream = (ImageInputStream) reader.getInput();
		ParameterBlockJAI pb = new ParameterBlockJAI("imageread");
		pb.setParameter("Input", istream);
		pb.setParameter("ReadParam", readParam);
		pb.setParameter("Reader", reader);
		img = JAI.create("imageread", pb);
		*/
	} catch (IOException e) {
		throw new FileOpException("Unable to load File!");
	}
	if (img == null) {
		throw new FileOpException("Unable to load File!");
	}
	imgFile = ii.getFile();
}
 
開發者ID:robcast,項目名稱:digilib,代碼行數:29,代碼來源:JAIImageLoaderDocuImage.java

示例3: copyReadParam

import javax.imageio.ImageReadParam; //導入方法依賴的package包/類
protected void copyReadParam(ImageReadParam src, ImageReadParam dst) {
    dst.setDestination(src.getDestination());
    dst.setSourceRegion(src.getSourceRegion());
    dst.setSourceSubsampling(src.getSourceXSubsampling(), src
            .getSourceYSubsampling(), src.getSubsamplingXOffset(), src
            .getSubsamplingYOffset());
    dst.setDestinationOffset(src.getDestinationOffset());
    if (ImageReaderFactory.getInstance().needsImageTypeSpecifier(tsuid)) {
        dst.setDestinationType(createImageTypeSpecifier());
    }
}
 
開發者ID:Sofd,項目名稱:viskit,代碼行數:12,代碼來源:RawDicomImageReader.java

示例4: readBandData

import javax.imageio.ImageReadParam; //導入方法依賴的package包/類
public void readBandData(int sourceOffsetX, int sourceOffsetY, int sourceWidth, int sourceHeight,
                         int sourceStepX, int sourceStepY, ProductData destBuffer, ProgressMonitor pm) throws IOException {
    pm.beginTask("Reading band ...", sourceHeight);
    try {
        ImageReadParam readParam = reader.getDefaultReadParam();
        readParam.setSourceBands(new int[]{0});
        readParam.setSourceSubsampling(sourceStepX, sourceStepY, 0, 0);
        readParam.setSourceRegion(new Rectangle(sourceOffsetX, sourceOffsetY, sourceWidth, sourceHeight));
        Raster raster;
        synchronized (lock) {
            raster = reader.readRaster(0, readParam);
        }

        DataBuffer dataBuffer = raster.getDataBuffer();
        int bufferSize = dataBuffer.getSize();
        switch (destBuffer.getType()) {
            case ProductData.TYPE_UINT8:
            case ProductData.TYPE_INT8:
            case ProductData.TYPE_INT32:
                for (int i = 0; i < bufferSize; i++) {
                    if (pm.isCanceled()) {
                        break;
                    }
                    destBuffer.setElemIntAt(i, dataBuffer.getElem(i));
                }
                break;
            case ProductData.TYPE_UINT16:
            case ProductData.TYPE_INT16:
                for (int i = 0; i < bufferSize; i++) {
                    if (pm.isCanceled()) {
                        break;
                    }
                    destBuffer.setElemUIntAt(i, swapBytes((short) dataBuffer.getElem(i)));
                }
                break;
            case ProductData.TYPE_UINT32:
                for (int i = 0; i < bufferSize; i++) {
                    if (pm.isCanceled()) {
                        break;
                    }
                    destBuffer.setElemUIntAt(i, dataBuffer.getElem(i));
                }
                break;
            case ProductData.TYPE_FLOAT32:
                for (int i = 0; i < bufferSize; i++) {
                    if (pm.isCanceled()) {
                        break;
                    }
                    destBuffer.setElemFloatAt(i, dataBuffer.getElemFloat(i));
                }
                break;
        }
        pm.worked(1);
    } catch (IOException e) {
        logger.severe(e.getMessage());
        throw e;
    } finally {
        pm.done();
    }
}
 
開發者ID:senbox-org,項目名稱:s2tbx,代碼行數:61,代碼來源:NITFReaderWrapper.java

示例5: readSLCRasterBand

import javax.imageio.ImageReadParam; //導入方法依賴的package包/類
public static double[] readSLCRasterBand(int x, int y, int width, int height) throws IOException {
	
	final double[] srcArray;
	
	final ImageReader reader = ImageIO.getImageReadersByFormatName("tiff").next();
	ImageInputStream iis = ImageIO.createImageInputStream(file);
	reader.setInput(iis);
	
	final ImageReadParam param = reader.getDefaultReadParam();
	param.setSourceSubsampling(width,height,0,0);

	final RenderedImage image = reader.readAsRenderedImage(0,param);
	
	
	final Raster data = image.getData(new Rectangle(0,0, width, height));

	final SampleModel sampleModel = data.getSampleModel();

	srcArray = new double[width * height];
	double[] samples = sampleModel.getSamples(0, 0, width, height, 0, srcArray,data.getDataBuffer());
	
	/*if (oneOfTwo)
		copyLine1Of2(srcArray, (short[]) destBuffer.getElems(), sourceStepX);
	else
		copyLine2Of2(srcArray, (short[]) destBuffer.getElems(), sourceStepX);*/
	
	return samples;
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:29,代碼來源:TestRaster.java


注:本文中的javax.imageio.ImageReadParam.setSourceSubsampling方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。