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


Java ImageReadParam.getSourceYSubsampling方法代碼示例

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


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

示例1: checkImageReadParam

import javax.imageio.ImageReadParam; //導入方法依賴的package包/類
/**
 * <p>
 * Validate that the specified {@link javax.imageio.ImageReadParam} contains
 * only the default values. If non-default values are present,
 * {@link java.io.IOException} is thrown.
 * </p>
 * 
 * @param param
 *            the <code>ImageReadParam</code> to be validated
 * @param head
 *            the <code>TGAHeader</code> that contains information about the
 *            source image
 * @throws IOException
 *             if the <code>ImageReadParam</code> contains non-default
 *             values
 */
private void checkImageReadParam(final ImageReadParam param, final TGAHeader header) throws IOException {
	if (param != null) {
		// get the image height and width from the header for convenience
		final int width = header.getWidth();
		final int height = header.getHeight();

		// ensure that the param contains only the defaults
		final Rectangle sourceROI = param.getSourceRegion();
		if ((sourceROI != null) && ((sourceROI.x != 0) || (sourceROI.y != 0) || (sourceROI.width != width) || (sourceROI.height != height))) {
			throw new IOException("The source region of interest is not the default."); // FIXME:
																						// localize
		} /* else -- the source ROI is the default */

		final Rectangle destinationROI = param.getSourceRegion();
		if ((destinationROI != null) && ((destinationROI.x != 0) || (destinationROI.y != 0) || (destinationROI.width != width) || (destinationROI.height != height))) {
			throw new IOException("The destination region of interest is not the default."); // FIXME:
																								// localize
		} /* else -- the destination ROI is the default */

		if ((param.getSourceXSubsampling() != 1) || (param.getSourceYSubsampling() != 1)) {
			throw new IOException("Source sub-sampling is not supported."); // FIXME:
																			// localize
		} /* else -- sub-sampling is the default */
	} /* else -- the ImageReadParam is null so the defaults *are* used */
}
 
開發者ID:xtremexp,項目名稱:UT4Converter,代碼行數:42,代碼來源:TGAImageReader.java

示例2: checkImageReadParam

import javax.imageio.ImageReadParam; //導入方法依賴的package包/類
/**
 * <p>Validate that the specified {@link javax.imageio.ImageReadParam} 
 * contains only the default values.  If non-default values are present,
 * {@link java.io.IOException} is thrown.</p>
 * 
 * @param  param the <code>ImageReadParam</code> to be validated
 * @param  head the <code>TGAHeader</code> that contains information about
 *         the source image
 * @throws IOException if the <code>ImageReadParam</code> contains non-default
 *         values
 */
private void checkImageReadParam(final ImageReadParam param,
                                 final TGAHeader header)
    throws IOException
{
    if(param != null)
    {
        // get the image height and width from the header for convenience
        final int width = header.getWidth();
        final int height = header.getHeight();
        
        // ensure that the param contains only the defaults
        final Rectangle sourceROI = param.getSourceRegion();
        if( (sourceROI != null) && 
            ( (sourceROI.x != 0) || (sourceROI.y != 0) ||
              (sourceROI.width != width) || (sourceROI.height != height) ) )
        {
            throw new IOException("The source region of interest is not the default."); // FIXME:  localize
        } /* else -- the source ROI is the default */

        final Rectangle destinationROI = param.getSourceRegion();
        if( (destinationROI != null) &&
            ( (destinationROI.x != 0) || (destinationROI.y != 0) ||
              (destinationROI.width != width) || (destinationROI.height != height) ) )
        {
            throw new IOException("The destination region of interest is not the default."); // FIXME:  localize
        } /* else -- the destination ROI is the default */

        if( (param.getSourceXSubsampling() != 1) || 
            (param.getSourceYSubsampling() != 1) )
        {
            throw new IOException("Source sub-sampling is not supported."); // FIXME:  localize
        } /* else -- sub-sampling is the default */
    } /* else -- the ImageReadParam is null so the defaults *are* used */
}
 
開發者ID:Katharsas,項目名稱:GMM,代碼行數:46,代碼來源:TGAImageReader.java

示例3: readRaster

import javax.imageio.ImageReadParam; //導入方法依賴的package包/類
@Override
    public Raster readRaster(int imageIndex, ImageReadParam param)
            throws IOException {
        checkIndex(imageIndex);

        Rectangle sourceRegion = new Rectangle();
        Rectangle destRegion = new Rectangle();
        computeRegions(param, getWidth(imageIndex), getHeight(imageIndex),
                       null, sourceRegion, destRegion);

        // Set everything to default values
        int sourceXSubsampling = param != null ? param.getSourceXSubsampling()
                : 1;
        int sourceYSubsampling = param != null ? param.getSourceYSubsampling()
                : 1;
        Point destinationOffset = param != null ? param.getDestinationOffset()
                : new Point(0, 0);

        ImageSubheader subheader;
        try {
            subheader = record.getImages()[imageIndex].getSubheader();
        } catch (NITFException e) {
            throw new IOException(ExceptionUtils.getStackTrace(e));
        }
//        String irep = subheader.getImageRepresentation().getStringData().trim();
        String pvType = subheader.getPixelValueType().getStringData().trim();
        int nbpp = subheader.getNumBitsPerPixel().getIntData();
        int bandCount = subheader.getBandCount();

        // make the band offsets array, for the output
        int[] bandOffsets;
        int[] sourceBands = param != null ? param.getSourceBands() : null;
        if (param != null && param.getDestinationBands() != null)
            bandOffsets = param.getDestinationBands();
        else if (param != null && sourceBands != null) {
            bandOffsets = new int[sourceBands.length];
            System.arraycopy(sourceBands, 0, bandOffsets, 0, bandOffsets.length);
        } else {
            // Setup band offsets -- TODO should we really read ALL bands by
            // default?
            bandOffsets = new int[bandCount];
            for (int i = 0; i < bandOffsets.length; i++)
                bandOffsets[i] = i;
        }

        int nBytes = ((nbpp - 1) / 8) + 1;

        int bufType;

        // byte
        if (nBytes == 1) {
            bufType = DataBuffer.TYPE_BYTE;
        }
        // short
        else if (nBytes == 2) {
            bufType = DataBuffer.TYPE_USHORT;
        }
        // float
        else if (nBytes == 4 && pvType.equals("R")) {
            bufType = DataBuffer.TYPE_FLOAT;
        }
        // double
        else if (nBytes == 8 && pvType.equals("R")) {
            bufType = DataBuffer.TYPE_DOUBLE;
        } else {
            throw new NotImplementedException("not yet implemented");
        }

        WritableRaster ras = ImageIOUtils
                .makeGenericPixelInterleavedWritableRaster(destRegion.width,
                                                           destRegion.height, bandOffsets.length, bufType);
        checkReadParamBandSettings(param, bandCount, ras.getSampleModel()
                .getNumBands());
        readRaster(imageIndex, sourceRegion, destRegion, sourceXSubsampling,
                   sourceYSubsampling, bandOffsets, nBytes, destinationOffset, ras);
        return ras;
    }
 
開發者ID:senbox-org,項目名稱:s2tbx,代碼行數:78,代碼來源:NITFReader.java

示例4: readRaster

import javax.imageio.ImageReadParam; //導入方法依賴的package包/類
/**
 * Read the raw raster data from the image, without any LUTs being applied.
 * Cannot read overlay data, as it isn't clear what the raster format should
 * be for those.
 */
@Override
public Raster readRaster(int imageIndex, ImageReadParam param)
        throws IOException {
    initImageReader(imageIndex);
    if (param == null) {
        param = getDefaultReadParam();
    }
    if (compressed) {
        ImageReadParam param1 = reader.getDefaultReadParam();
        copyReadParam(param, param1);
        return decompressRaster(imageIndex, param1);
    }
    if( pmi.endsWith("422") || pmi.endsWith("420") ) {
        log.debug("Using a 422/420 partial component image reader.");
        if( param.getSourceXSubsampling()!=1
                || param.getSourceYSubsampling()!=1
                || param.getSourceRegion()!=null )
        {
            log.warn("YBR_*_422 and 420 reader does not support source sub-sampling or source region.");
            throw new UnsupportedOperationException("Implement sub-sampling/soure region.");
        }
        SampleModel sm = createSampleModel();
        WritableRaster wr = Raster.createWritableRaster(sm, new Point());
        DataBufferByte dbb = (DataBufferByte) wr.getDataBuffer();
        byte[] data = dbb.getData();
        log.debug("Seeking to "+(pixelDataPos + imageIndex * data.length)+" and reading "+data.length+" bytes.");
        iis.seek(pixelDataPos + imageIndex * data.length);
        iis.read(data);
        if (swapByteOrder) {
            ByteUtils.toggleShortEndian(data);
        }
        return wr;
    }
    Raster raster = reader.readRaster(imageIndex, param);
    if (swapByteOrder) {
        ByteUtils.toggleShortEndian(
                ((DataBufferByte)raster.getDataBuffer()).getData());
    }
    return raster;
}
 
開發者ID:Sofd,項目名稱:viskit,代碼行數:46,代碼來源:RawDicomImageReader.java


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