本文整理汇总了Java中java.awt.image.ComponentSampleModel.getNumBands方法的典型用法代码示例。如果您正苦于以下问题:Java ComponentSampleModel.getNumBands方法的具体用法?Java ComponentSampleModel.getNumBands怎么用?Java ComponentSampleModel.getNumBands使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.ComponentSampleModel
的用法示例。
在下文中一共展示了ComponentSampleModel.getNumBands方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createImageLayout
import java.awt.image.ComponentSampleModel; //导入方法依赖的package包/类
public static LCMSImageLayout createImageLayout(Raster r) {
LCMSImageLayout l = new LCMSImageLayout();
if (r instanceof ByteComponentRaster &&
r.getSampleModel() instanceof ComponentSampleModel) {
ByteComponentRaster br = (ByteComponentRaster)r;
ComponentSampleModel csm = (ComponentSampleModel)r.getSampleModel();
l.pixelType = CHANNELS_SH(br.getNumBands()) | BYTES_SH(1);
int[] bandOffsets = csm.getBandOffsets();
BandOrder order = BandOrder.getBandOrder(bandOffsets);
int firstBand = 0;
switch (order) {
case INVERTED:
l.pixelType |= DOSWAP;
firstBand = csm.getNumBands() - 1;
break;
case DIRECT:
// do nothing
break;
default:
// unable to create the image layout;
return null;
}
l.nextRowOffset = br.getScanlineStride();
l.nextPixelOffset = br.getPixelStride();
l.offset = br.getDataOffset(firstBand);
l.dataArray = br.getDataStorage();
l.dataType = DT_BYTE;
l.width = br.getWidth();
l.height = br.getHeight();
if (l.nextRowOffset == l.width * br.getPixelStride()) {
l.imageAtOnce = true;
}
return l;
}
return null;
}
示例2: imageIsContiguous
import java.awt.image.ComponentSampleModel; //导入方法依赖的package包/类
/**
* Returns whether the image has contiguous data across rows.
*/
public static final boolean imageIsContiguous(RenderedImage image) {
SampleModel sm;
if(image instanceof BufferedImage) {
WritableRaster ras = ((BufferedImage)image).getRaster();
sm = ras.getSampleModel();
} else {
sm = image.getSampleModel();
}
if (sm instanceof ComponentSampleModel) {
// Ensure image rows samples are stored contiguously
// in a single bank.
ComponentSampleModel csm = (ComponentSampleModel)sm;
if (csm.getPixelStride() != csm.getNumBands()) {
return false;
}
int[] bandOffsets = csm.getBandOffsets();
for (int i = 0; i < bandOffsets.length; i++) {
if (bandOffsets[i] != i) {
return false;
}
}
int[] bankIndices = csm.getBankIndices();
for (int i = 0; i < bandOffsets.length; i++) {
if (bankIndices[i] != 0) {
return false;
}
}
return true;
}
// Otherwise true if and only if it's a bilevel image with
// a MultiPixelPackedSampleModel, 1 bit per pixel, and 1 bit
// pixel stride.
return ImageUtil.isBinary(sm);
}
示例3: filter
import java.awt.image.ComponentSampleModel; //导入方法依赖的package包/类
public WritableRaster filter(Raster src, WritableRaster dest)
{
if (dest == null)
dest = createCompatibleDestRaster(src);
DataBuffer srcDB = src.getDataBuffer();
DataBuffer destDB = dest.getDataBuffer();
ComponentSampleModel srcSM = (ComponentSampleModel) src.getSampleModel();
ComponentSampleModel destSM = (ComponentSampleModel) dest.getSampleModel();
// Calculate offset to data in the underlying arrays:
int srcScanlineStride = srcSM.getScanlineStride();
int destScanlineStride = destSM.getScanlineStride();
int srcX = src.getMinX() - src.getSampleModelTranslateX();
int srcY = src.getMinY() - src.getSampleModelTranslateY();
int destX = dest.getMinX() - dest.getSampleModelTranslateX();
int destY = dest.getMinY() - dest.getSampleModelTranslateY();
int numBands = srcSM.getNumBands();
/* We can't use getOffset(x, y) from the sample model since we
don't want the band offset added in. */
int srcOffset =
numBands*srcX + srcScanlineStride*srcY + // from sample model
srcDB.getOffset(); // from data buffer
int destOffset =
numBands*destX + destScanlineStride*destY + // from sample model
destDB.getOffset(); // from data buffer
// Determine how much, and how many times to blit.
int rowSize = src.getWidth()*numBands;
int h = src.getHeight();
if ((rowSize == srcScanlineStride) &&
(rowSize == destScanlineStride))
{
// collapse scan line blits to one large blit.
rowSize *= h;
h = 1;
}
// Do blitting
Object srcArray = Buffers.getData(srcDB);
Object destArray = Buffers.getData(destDB);
for (int yd = 0; yd<h; yd++)
{
System.arraycopy(srcArray, srcOffset,
destArray, destOffset,
rowSize);
srcOffset += srcScanlineStride;
destOffset += destScanlineStride;
}
return dest;
}
示例4: filter
import java.awt.image.ComponentSampleModel; //导入方法依赖的package包/类
public WritableRaster filter(Raster src, WritableRaster dest)
{
if (dest == null)
dest = createCompatibleDestRaster(src);
DataBuffer srcDB = src.getDataBuffer();
DataBuffer destDB = dest.getDataBuffer();
ComponentSampleModel srcSM = (ComponentSampleModel) src.getSampleModel();
ComponentSampleModel destSM = (ComponentSampleModel) dest.getSampleModel();
// Calculate offset to data in the underlying arrays:
int srcScanlineStride = srcSM.getScanlineStride();
int destScanlineStride = destSM.getScanlineStride();
int srcX = src.getMinX() - src.getSampleModelTranslateX();
int srcY = src.getMinY() - src.getSampleModelTranslateY();
int destX = dest.getMinX() - dest.getSampleModelTranslateX();
int destY = dest.getMinY() - dest.getSampleModelTranslateY();
int numBands = srcSM.getNumBands();
/* We can't use getOffset(x, y) from the sample model since we
don't want the band offset added in. */
int srcOffset =
numBands*srcX + srcScanlineStride*srcY + // from sample model
srcDB.getOffset(); // from data buffer
int destOffset =
numBands*destX + destScanlineStride*destY + // from sample model
destDB.getOffset(); // from data buffer
// Determine how much, and how many times to blit.
int rowSize = src.getWidth()*numBands;
int h = src.getHeight();
if ((rowSize == srcScanlineStride) &&
(rowSize == destScanlineStride))
{
// collapse scan line blits to one large blit.
rowSize *= h;
h = 1;
}
// Do blitting
Object srcArray = Buffers.getData(srcDB);
Object destArray = Buffers.getData(destDB);
for (int yd = 0; yd<h; yd++)
{
System.arraycopy(srcArray, srcOffset,
destArray, destOffset,
rowSize);
srcOffset += srcScanlineStride;
destOffset += destScanlineStride;
}
return dest;
}
示例5: createImageLayout
import java.awt.image.ComponentSampleModel; //导入方法依赖的package包/类
public static LCMSImageLayout createImageLayout(Raster r) {
LCMSImageLayout l = new LCMSImageLayout();
if (r instanceof ByteComponentRaster) {
ByteComponentRaster br = (ByteComponentRaster)r;
ComponentSampleModel csm = (ComponentSampleModel)r.getSampleModel();
l.pixelType = CHANNELS_SH(br.getNumBands()) | BYTES_SH(1);
int[] bandOffsets = csm.getBandOffsets();
BandOrder order = BandOrder.getBandOrder(bandOffsets);
int firstBand = 0;
switch (order) {
case INVERTED:
l.pixelType |= DOSWAP;
firstBand = csm.getNumBands() - 1;
break;
case DIRECT:
// do nothing
break;
default:
// unable to create the image layout;
return null;
}
l.nextRowOffset = br.getScanlineStride();
l.nextPixelOffset = br.getPixelStride();
l.offset = br.getDataOffset(firstBand);
l.dataArray = br.getDataStorage();
l.dataType = DT_BYTE;
l.width = br.getWidth();
l.height = br.getHeight();
if (l.nextRowOffset == l.width * br.getPixelStride()) {
l.imageAtOnce = true;
}
return l;
}
return null;
}
示例6: imageIsContiguous
import java.awt.image.ComponentSampleModel; //导入方法依赖的package包/类
/**
* Returns whether the image has contiguous data across rows.
*/
public static final boolean imageIsContiguous(RenderedImage image) {
SampleModel sm;
if(image instanceof BufferedImage) {
WritableRaster ras = ((BufferedImage)image).getRaster();
sm = ras.getSampleModel();
} else {
sm = image.getSampleModel();
}
if (sm instanceof ComponentSampleModel) {
// Ensure image rows samples are stored contiguously
// in a single bank.
ComponentSampleModel csm = (ComponentSampleModel)sm;
if (csm.getPixelStride() != csm.getNumBands()) {
return false;
}
int[] bandOffsets = csm.getBandOffsets();
for (int i = 0; i < bandOffsets.length; i++) {
if (bandOffsets[i] != i) {
return false;
}
}
int[] bankIndices = csm.getBankIndices();
for (int i = 0; i < bandOffsets.length; i++) {
if (bankIndices[i] != 0) {
return false;
}
}
return true;
}
// Otherwise true if and only if it's a bilevel image with
// a MultiPixelPackedSampleModel, 1 bit per pixel, and 1 bit
// pixel stride.
return ImageUtil.isBinary(sm);
}