本文整理汇总了Java中javax.imageio.ImageReadParam.getDestinationOffset方法的典型用法代码示例。如果您正苦于以下问题:Java ImageReadParam.getDestinationOffset方法的具体用法?Java ImageReadParam.getDestinationOffset怎么用?Java ImageReadParam.getDestinationOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.imageio.ImageReadParam
的用法示例。
在下文中一共展示了ImageReadParam.getDestinationOffset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: read
import javax.imageio.ImageReadParam; //导入方法依赖的package包/类
public BufferedImage read(int imageIndex, ImageReadParam param)
throws IOException {
if (param == null)
param = getDefaultReadParam();
checkIndex(imageIndex);
clearAbortRequest();
processImageStarted(imageIndex);
BufferedImage bi = param.getDestination();
RawRenderedImage image =
new RawRenderedImage(iis, this, param, imageIndex);
Point offset = param.getDestinationOffset();
WritableRaster raster;
if (bi == null) {
ColorModel colorModel = image.getColorModel();
SampleModel sampleModel = image.getSampleModel();
// If the destination type is specified, use the color model of it.
ImageTypeSpecifier type = param.getDestinationType();
if (type != null)
colorModel = type.getColorModel();
raster = Raster.createWritableRaster(
sampleModel.createCompatibleSampleModel(image.getMinX()+
image.getWidth(),
image.getMinY() +
image.getHeight()),
new Point(0, 0));
bi = new BufferedImage(colorModel,
raster,
colorModel != null ?
colorModel.isAlphaPremultiplied() : false,
new Hashtable());
} else {
raster = bi.getWritableTile(0, 0);
}
image.setDestImage(bi);
image.readAsRaster(raster);
image.clearDestImage();
if (abortRequested())
processReadAborted();
else
processImageComplete();
return bi;
}