本文整理汇总了Java中java.awt.image.DataBuffer.getDataTypeSize方法的典型用法代码示例。如果您正苦于以下问题:Java DataBuffer.getDataTypeSize方法的具体用法?Java DataBuffer.getDataTypeSize怎么用?Java DataBuffer.getDataTypeSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.DataBuffer
的用法示例。
在下文中一共展示了DataBuffer.getDataTypeSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getElementSize
import java.awt.image.DataBuffer; //导入方法依赖的package包/类
public static int getElementSize(SampleModel sm) {
int elementSize = DataBuffer.getDataTypeSize(sm.getDataType());
if (sm instanceof MultiPixelPackedSampleModel) {
MultiPixelPackedSampleModel mppsm =
(MultiPixelPackedSampleModel)sm;
return mppsm.getSampleSize(0) * mppsm.getNumBands();
} else if (sm instanceof ComponentSampleModel) {
return sm.getNumBands() * elementSize;
} else if (sm instanceof SinglePixelPackedSampleModel) {
return elementSize;
}
return elementSize * sm.getNumBands();
}
示例2: getBandSize
import java.awt.image.DataBuffer; //导入方法依赖的package包/类
public static long getBandSize(SampleModel sm) {
int elementSize = DataBuffer.getDataTypeSize(sm.getDataType());
if (sm instanceof ComponentSampleModel) {
ComponentSampleModel csm = (ComponentSampleModel)sm;
int pixelStride = csm.getPixelStride();
int scanlineStride = csm.getScanlineStride();
long size = Math.min(pixelStride, scanlineStride);
if (pixelStride > 0)
size += pixelStride * (sm.getWidth() - 1);
if (scanlineStride > 0)
size += scanlineStride * (sm.getHeight() - 1);
return size * ((elementSize + 7) / 8);
} else
return getTileSize(sm);
}
示例3: createComponentCM
import java.awt.image.DataBuffer; //导入方法依赖的package包/类
static ColorModel createComponentCM(ColorSpace colorSpace,
int numBands,
int dataType,
boolean hasAlpha,
boolean isAlphaPremultiplied) {
int transparency =
hasAlpha ? Transparency.TRANSLUCENT : Transparency.OPAQUE;
int[] numBits = new int[numBands];
int bits = DataBuffer.getDataTypeSize(dataType);
for (int i = 0; i < numBands; i++) {
numBits[i] = bits;
}
return new ComponentColorModel(colorSpace,
numBits,
hasAlpha,
isAlphaPremultiplied,
transparency,
dataType);
}
示例4: doTest
import java.awt.image.DataBuffer; //导入方法依赖的package包/类
private static void doTest(int dataType) {
int maxSize = DataBuffer.getDataTypeSize(dataType);
System.out.println("Type size: " + maxSize);
int theMask = (int)(1L << (maxSize + 2)) - 1;
System.out.printf("theMask=%x\n", theMask);
SinglePixelPackedSampleModel sm =
new SinglePixelPackedSampleModel(dataType, w, h,
new int[] { theMask });
int[] sampleSize = sm.getSampleSize();
for (int s : sampleSize) {
if (s > maxSize) {
throw new RuntimeException("Test failed: sample size is too big:" + s);
}
}
System.out.println("Test medialib...");
DataBuffer buf = createDataBuffer(dataType);
WritableRaster wr = Raster.createWritableRaster(sm, buf, null);
op.filter(wr, null);
System.out.println("Test PASSED.");
}