本文整理了Java中java.awt.image.Raster.getSampleModel
方法的一些代码示例,展示了Raster.getSampleModel
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Raster.getSampleModel
方法的具体详情如下:
包路径:java.awt.image.Raster
类名称:Raster
方法名:getSampleModel
暂无
代码示例来源:origin: geotools/geotools
/** Returns {@code true} if {@code raster} is compatible with this {@code ColorModel}. */
public boolean isCompatibleRaster(final Raster raster) {
return isCompatibleSampleModel(raster.getSampleModel());
}
代码示例来源:origin: haraldk/TwelveMonkeys
final int stride = (tile.getSampleModel().getWidth() * sampleSize + 7) / 8;
final DataBuffer dataBuffer = tile.getDataBuffer();
代码示例来源:origin: haraldk/TwelveMonkeys
@Override
public final boolean isCompatibleRaster(final Raster raster) {
int size = raster.getSampleModel().getSampleSize(0);
return ((raster.getTransferType() == transferType) &&
(raster.getNumBands() == 2) && ((1 << size) >= icm.getMapSize()));
}
代码示例来源:origin: haraldk/TwelveMonkeys
InvertedRaster(final Raster raster) {
super(raster.getSampleModel(), new DataBuffer(raster.getDataBuffer().getDataType(), raster.getDataBuffer().getSize()) {
private final DataBuffer delegate = raster.getDataBuffer();
@Override
public int getElem(final int bank, final int i) {
return (255 - delegate.getElem(bank, i));
}
@Override
public void setElem(int bank, int i, int val) {
throw new UnsupportedOperationException("setElem");
}
}, new Point());
}
}
代码示例来源:origin: geotools/geotools
name,
(min == null || max == null) ? RectIterFactory.create(raster, null) : null,
raster.getSampleModel(),
min,
max,
代码示例来源:origin: haraldk/TwelveMonkeys
private void writeImageData(final IIOImage image) throws IOException {
// - dump data as is (or convert, if TYPE_INT_xxx)
// Enforce RGB/CMYK order for such data!
// TODO: Loop over x/y tiles, using 0,0 is only valid for BufferedImage
// TODO: PNM/PAM does not support tiling, we must iterate all tiles along the x-axis for each row we write
Raster tile = image.hasRaster() ? image.getRaster() : image.getRenderedImage().getTile(0, 0);
SampleModel sampleModel = tile.getSampleModel();
DataBuffer dataBuffer = tile.getDataBuffer();
int tileWidth = tile.getWidth();
int tileHeight = tile.getHeight();
final int transferType = sampleModel.getTransferType();
Object data = null;
for (int y = 0; y < tileHeight; y++) {
data = sampleModel.getDataElements(0, y, tileWidth, 1, data, dataBuffer);
// TODO: Support other (short, float) data types
if (transferType == DataBuffer.TYPE_BYTE) {
imageOutput.write((byte[]) data);
}
else if (transferType == DataBuffer.TYPE_USHORT) {
short[] shortData = (short[]) data;
imageOutput.writeShorts(shortData, 0, shortData.length);
}
processImageProgress(y * 100f / tileHeight); // TODO: Take tile y into account
if (abortRequested()) {
processWriteAborted();
break;
}
}
}
代码示例来源:origin: haraldk/TwelveMonkeys
int[] bitOffsets = null;
if (src.getTransferType() == DataBuffer.TYPE_USHORT) {
if (src.getSampleModel() instanceof SinglePixelPackedSampleModel) {
SinglePixelPackedSampleModel sampleModel = (SinglePixelPackedSampleModel) src.getSampleModel();
bitMasks = sampleModel.getBitMasks();
bitOffsets = sampleModel.getBitOffsets();
代码示例来源:origin: haraldk/TwelveMonkeys
int[] bitOffsets = null;
if (src.getTransferType() == DataBuffer.TYPE_USHORT) {
if (src.getSampleModel() instanceof SinglePixelPackedSampleModel) {
SinglePixelPackedSampleModel sampleModel = (SinglePixelPackedSampleModel) src.getSampleModel();
bitMasks = sampleModel.getBitMasks();
bitOffsets = sampleModel.getBitOffsets();
代码示例来源:origin: geotools/geotools
final int w = sourceRaster.getWidth();
final int h = sourceRaster.getHeight();
final int numBands = sourceRaster.getSampleModel().getNumBands();
final int[] rgba = new int[numBands];
final boolean sourceHasAlpha = sourceColorModel.hasAlpha();
代码示例来源:origin: geotools/geotools
final int dstMinX = src.getMinX();
final int dstMinY = src.getMinY();
final int numBands = src.getSampleModel().getNumBands();
final boolean sourceHasAlpha = (numBands % 2 == 0);
final int alphaBand = sourceHasAlpha ? numBands - 1 : -1;
代码示例来源:origin: haraldk/TwelveMonkeys
int bank = banded ? ((BandedSampleModel) tileRowRaster.getSampleModel()).getBankIndices()[band] : band;
代码示例来源:origin: org.geotools/gt-coverage
/**
* Returns {@code true} if {@code raster} is compatible
* with this {@code ColorModel}.
*/
public boolean isCompatibleRaster(final Raster raster) {
return isCompatibleSampleModel(raster.getSampleModel());
}
代码示例来源:origin: MegaMek/mekhq
private void validateRaster(Raster r) {
if(r.getSampleModel().getDataType() != DataBuffer.TYPE_INT) {
throw new IllegalArgumentException("Raster sample type has to be integer");
}
}
代码示例来源:origin: ru.sbtqa/monte-media
public ICCPackedColorModel(ICC_ColorSpace colorSpace, Raster raster) {
// FIXME this super call silently only handles rasters without alpha channel!
super(colorSpace,//
getBits(raster),//
((SinglePixelPackedSampleModel) raster.getSampleModel()).getBitMasks(), 0, true, OPAQUE, raster.getTransferType());
this.colorSpace = colorSpace;
this.maskArray = ((SinglePixelPackedSampleModel) raster.getSampleModel()).getBitMasks();
this.maskOffsets = ((SinglePixelPackedSampleModel) raster.getSampleModel()).getBitOffsets();
}
代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik
public WritableRaster createCompatibleDestRaster(Raster src){
checkCompatible(src.getSampleModel());
// Src Raster is OK: create a similar Raster for destination.
return src.createCompatibleWritableRaster();
}
代码示例来源:origin: Geomatys/geotoolkit
@Override
public boolean isCompatibleRaster(Raster raster) {
final SampleModel sm = raster.getSampleModel();
if (!(sm instanceof ComponentSampleModel))
return false;
for (int i = 0; i < bits.length; i++) {
if (sm.getSampleSize(i) < bits[i]) return false;
}
return (raster.getTransferType() == transferType);
}
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-png
public RasterIntABGRProvider(Raster raster, boolean hasAlpha) {
super(raster, 8, raster.getWidth() * (hasAlpha ? 4 : 3));
this.pixels = ((DataBufferInt) raster.getDataBuffer()).getData();
this.hasAlpha = hasAlpha;
if (hasAlpha) {
bgrOrder = false;
} else {
int[] offsets = ((SinglePixelPackedSampleModel) raster.getSampleModel()).getBitOffsets();
bgrOrder = offsets[0] != 0;
}
}
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-png
public RasterShortGrayAlphaProvider(Raster raster) {
super(raster, 16, raster.getWidth() * 4);
this.shorts = ((DataBufferUShort) raster.getDataBuffer()).getData();
int[] bandOffsets = ((PixelInterleavedSampleModel) raster.getSampleModel()).getBandOffsets();
this.alphaFirst = bandOffsets[0] != 0;
}
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-png
public RasterShortABGRProvider(Raster raster, boolean hasAlpha) {
super(raster, 16, (hasAlpha ? 8 : 6) * raster.getWidth());
this.hasAlpha = hasAlpha;
shorts = ((DataBufferUShort) raster.getDataBuffer()).getData();
bgrOrder = ((ComponentSampleModel) raster.getSampleModel()).getBandOffsets()[0] != 0;
}
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-png
public RasterByteGrayAlphaProvider(Raster raster) {
super(raster, 8, raster.getWidth() * computePixelStride(raster, PIXEL_STRIDES));
this.bytes = ((DataBufferByte) raster.getDataBuffer()).getData();
ComponentSampleModel sm = (ComponentSampleModel) raster.getSampleModel();
this.bandOffsets = sm.getBandOffsets();
this.numBands = sm.getNumBands();
this.pixelStride = sm.getPixelStride();
this.alphaFirst = bandOffsets[0] != 0;
}
内容来源于网络,如有侵权,请联系作者删除!