本文整理汇总了Java中java.awt.image.ComponentSampleModel.getBankIndices方法的典型用法代码示例。如果您正苦于以下问题:Java ComponentSampleModel.getBankIndices方法的具体用法?Java ComponentSampleModel.getBankIndices怎么用?Java ComponentSampleModel.getBankIndices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.ComponentSampleModel
的用法示例。
在下文中一共展示了ComponentSampleModel.getBankIndices方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RectIterCSM
import java.awt.image.ComponentSampleModel; //导入方法依赖的package包/类
public RectIterCSM(RenderedImage im, Rectangle bounds) {
super(im, bounds);
ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
this.scanlineStride = csm.getScanlineStride();
this.pixelStride = csm.getPixelStride();
this.bankIndices = csm.getBankIndices();
int[] bo = csm.getBandOffsets();
this.bandOffsets = new int[numBands + 1];
for (int i = 0; i < numBands; i++) {
bandOffsets[i] = bo[i];
}
bandOffsets[numBands] = 0;
this.DBOffsets = new int[numBands];
this.offset = (y - sampleModelTranslateY)*scanlineStride +
(x - sampleModelTranslateX)*pixelStride;
this.bandOffset = bandOffsets[0];
}
示例2: isInterleaved
import java.awt.image.ComponentSampleModel; //导入方法依赖的package包/类
/*** Analyzes a ComponentSampleModel to determine if it can function
* as a PixelInterleavedSampleModel. In order to do so, it must use
* only bank 0 of its DataBuffer, and the data offsets must span a range
* of less than pixelStride.
*
* <p> These properties are trivially true for a 1-banded SampleModel.
*/
private boolean isInterleaved(ComponentSampleModel sm) {
// Analyze ComponentSampleModel to determine if it has the
// properties of a PixelInterleavedSampleModel
int numBands = sampleModel.getNumBands();
if (numBands == 1) {
return true;
}
// Determine banks used
int[] bankIndices = sm.getBankIndices();
for (int i = 0; i < numBands; i++) {
if (bankIndices[i] != 0) {
return false;
}
}
// Determine range of band offsets
int[] bandOffsets = sm.getBandOffsets();
int minOffset = bandOffsets[0];
int maxOffset = minOffset;
for (int i = 1; i < numBands; i++) {
int offset = bandOffsets[i];
if (offset < minOffset) {
minOffset = offset;
}
if (offset > maxOffset) {
maxOffset = offset;
}
}
if (maxOffset - minOffset >= sm.getPixelStride()) {
return false;
}
return true;
}
示例3: getNumBanksCSM
import java.awt.image.ComponentSampleModel; //导入方法依赖的package包/类
private static long getNumBanksCSM(ComponentSampleModel csm) {
int[] bankIndices = csm.getBankIndices();
int maxIndex = bankIndices[0];
for(int i = 1; i < bankIndices.length; i++) {
int bankIndex = bankIndices[i];
if(bankIndex > maxIndex) {
maxIndex = bankIndex;
}
}
return maxIndex + 1;
}
示例4: extractComponentRGBInt
import java.awt.image.ComponentSampleModel; //导入方法依赖的package包/类
private static byte[] extractComponentRGBInt( int aWidth, int aHeight, ComponentSampleModel aSampleModel, DataBufferInt aDataBuffer ) {
byte[] out = new byte[ aWidth * aHeight * 3 ];
int[] bankIndices = aSampleModel.getBankIndices();
int[] bankOffsets = aSampleModel.getBandOffsets();
int rScanIx = bankOffsets[ 0 ];
int gScanIx = bankOffsets[ 1 ];
int bScanIx = bankOffsets[ 2 ];
int pixelStride = aSampleModel.getPixelStride();
int scanlineStride = aSampleModel.getScanlineStride();
for ( int b = 0, y = 0; y < aHeight; y++ ) {
int rPixIx = rScanIx;
int gPixIx = gScanIx;
int bPixIx = bScanIx;
for ( int x = 0; x < aWidth; x++, b += 3 ) {
out[b] = (byte) aDataBuffer.getElem(bankIndices[0], rPixIx);
rPixIx += pixelStride;
out[b + 1] = (byte) aDataBuffer.getElem(bankIndices[1], gPixIx);
gPixIx += pixelStride;
out[b + 2] = (byte) aDataBuffer.getElem(bankIndices[2], bPixIx);
bPixIx += pixelStride;
}
rScanIx += scanlineStride;
gScanIx += scanlineStride;
bScanIx += scanlineStride;
}
return out;
}
示例5: extractComponentRGBByte
import java.awt.image.ComponentSampleModel; //导入方法依赖的package包/类
private static byte[] extractComponentRGBByte( int aWidth, int aHeight, ComponentSampleModel aSampleModel, DataBufferByte aDataBuffer ) {
byte[] out = new byte[ aWidth * aHeight * 3 ];
int[] bankIndices = aSampleModel.getBankIndices();
int[] bankOffsets = aSampleModel.getBandOffsets();
int rScanIx = bankOffsets[ 0 ];
int gScanIx = bankOffsets[ 1 ];
int bScanIx = bankOffsets[ 2 ];
int pixelStride = aSampleModel.getPixelStride();
int scanlineStride = aSampleModel.getScanlineStride();
for ( int b = 0, y = 0; y < aHeight; y++ ) {
int rPixIx = rScanIx;
int gPixIx = gScanIx;
int bPixIx = bScanIx;
for ( int x = 0; x < aWidth; x++, b += 3 ) {
out[b] = (byte) aDataBuffer.getElem(bankIndices[0], rPixIx);
rPixIx += pixelStride;
out[b + 1] = (byte) aDataBuffer.getElem(bankIndices[1], gPixIx);
gPixIx += pixelStride;
out[b + 2] = (byte) aDataBuffer.getElem(bankIndices[2], bPixIx);
bPixIx += pixelStride;
}
rScanIx += scanlineStride;
gScanIx += scanlineStride;
bScanIx += scanlineStride;
}
return out;
}
示例6: extractComponentRGBAInt
import java.awt.image.ComponentSampleModel; //导入方法依赖的package包/类
private static byte[] extractComponentRGBAInt( int aWidth, int aHeight, ComponentSampleModel aSampleModel, DataBufferInt aDataBuffer ) {
byte[] out = new byte[ aWidth * aHeight * 4 ];
int[] bankIndices = aSampleModel.getBankIndices();
int[] bankOffsets = aSampleModel.getBandOffsets();
int rScanIx = bankOffsets[ 0 ];
int gScanIx = bankOffsets[ 1 ];
int bScanIx = bankOffsets[ 2 ];
int aScanIx = bankOffsets[ 3 ];
int pixelStride = aSampleModel.getPixelStride();
int scanlineStride = aSampleModel.getScanlineStride();
for ( int b = 0, y = 0; y < aHeight; y++ ) {
int rPixIx = rScanIx;
int gPixIx = gScanIx;
int bPixIx = bScanIx;
int aPixIx = aScanIx;
for ( int x = 0; x < aWidth; x++, b += 4 ) {
out[b] = (byte) aDataBuffer.getElem(bankIndices[0], rPixIx);
rPixIx += pixelStride;
out[b + 1] = (byte) aDataBuffer.getElem(bankIndices[1], gPixIx);
gPixIx += pixelStride;
out[b + 2] = (byte) aDataBuffer.getElem(bankIndices[2], bPixIx);
bPixIx += pixelStride;
out[b + 3] = (byte) aDataBuffer.getElem(bankIndices[3], aPixIx);
aPixIx += pixelStride;
}
rScanIx += scanlineStride;
gScanIx += scanlineStride;
bScanIx += scanlineStride;
aScanIx += scanlineStride;
}
return out;
}
示例7: extractComponentRGBAByte
import java.awt.image.ComponentSampleModel; //导入方法依赖的package包/类
private static byte[] extractComponentRGBAByte( int aWidth, int aHeight, ComponentSampleModel aSampleModel, DataBufferByte aDataBuffer ) {
byte[] out = new byte[ aWidth * aHeight * 4 ];
int[] bankIndices = aSampleModel.getBankIndices();
int[] bankOffsets = aSampleModel.getBandOffsets();
int rScanIx = bankOffsets[ 0 ];
int gScanIx = bankOffsets[ 1 ];
int bScanIx = bankOffsets[ 2 ];
int aScanIx = bankOffsets[ 3 ];
int pixelStride = aSampleModel.getPixelStride();
int scanlineStride = aSampleModel.getScanlineStride();
for ( int b = 0, y = 0; y < aHeight; y++ ) {
int rPixIx = rScanIx;
int gPixIx = gScanIx;
int bPixIx = bScanIx;
int aPixIx = aScanIx;
for ( int x = 0; x < aWidth; x++, b += 4 ) {
out[b] = (byte) aDataBuffer.getElem(bankIndices[0], rPixIx);
rPixIx += pixelStride;
out[b + 1] = (byte) aDataBuffer.getElem(bankIndices[1], gPixIx);
gPixIx += pixelStride;
out[b + 2] = (byte) aDataBuffer.getElem(bankIndices[2], bPixIx);
bPixIx += pixelStride;
out[b + 3] = (byte) aDataBuffer.getElem(bankIndices[3], aPixIx);
aPixIx += pixelStride;
}
rScanIx += scanlineStride;
gScanIx += scanlineStride;
bScanIx += scanlineStride;
aScanIx += scanlineStride;
}
return out;
}
示例8: 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);
}
示例9: RasterFormatTag
import java.awt.image.ComponentSampleModel; //导入方法依赖的package包/类
/**
* Constructs a RasterFormatTag given a sampleModel and a
* formatTagID. Generally, this constructor is called by
* RasterAccessor.findCompatibleTags(RenderedImage[] srcs,
* RenderedImage dst) and it takes care of setting the values
* correctly. In special cases, OpImages need to construct
* a RasterFormatTag without creating a RenderedImage. In this
* case a RasterFormatTag can be created using a formatTagID
* returned from
* RasterAccessor.findCompatibleTag(SampleModel[] srcs, SampleModel dst)
* and a sampleModel that was either passed in to the
* findCompatibleTag() call or one that was created using
* createCompatibleSampleModel() on one of the passed in
* SampleModels. Attempting to use arbitrary SampleModels
* with arbitrary formatTagIDs has undefined results.
*
* param sampleModel A <code>SampleModel</code> for the RasterFormagTag
* param formatTagID An <code>int</code> to indicate format tag id
*
*/
public RasterFormatTag(SampleModel sampleModel, int formatTagID) {
this.formatTagID = formatTagID;
if ((formatTagID & COPY_MASK) == UNCOPIED) {
ComponentSampleModel csm =
(ComponentSampleModel)sampleModel;
this.bankIndices = csm.getBankIndices();
this.numBands = csm.getNumDataElements();
this.bandOffsets = csm.getBandOffsets();
this.pixelStride = csm.getPixelStride();
if (pixelStride != bandOffsets.length) {
isPixelSequential = false;
} else {
isPixelSequential = true;
for (int i = 0; i < bandOffsets.length; i++) {
if (bandOffsets[i] >= pixelStride ||
bankIndices[i] != bankIndices[0]) {
isPixelSequential = false;
}
for (int j = i+1; j < bandOffsets.length; j++) {
if (bandOffsets[i] == bandOffsets[j]) {
isPixelSequential = false;
}
}
if (!isPixelSequential) break;
}
}
} else if ((formatTagID & COPY_MASK) == COPIED) {
numBands = sampleModel.getNumBands();
bandOffsets = new int[numBands];
pixelStride = numBands;
bankIndices = new int[numBands];
for (int i = 0; i < numBands; i++) {
bandOffsets[i] = i;
bankIndices[i] = 0;
}
isPixelSequential = true;
}
}
示例10: 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);
}