本文整理汇总了Java中java.awt.color.ColorSpace.getNumComponents方法的典型用法代码示例。如果您正苦于以下问题:Java ColorSpace.getNumComponents方法的具体用法?Java ColorSpace.getNumComponents怎么用?Java ColorSpace.getNumComponents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.color.ColorSpace
的用法示例。
在下文中一共展示了ColorSpace.getNumComponents方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Context
import java.awt.color.ColorSpace; //导入方法依赖的package包/类
public Context(TestEnvironment env, Result result, ColorSpace cs) {
this.cs = cs;
this.env = env;
this.res = result;
numComponents = cs.getNumComponents();
val = new float[numComponents];
for (int i = 0; i < numComponents; i++) {
float min = cs.getMinValue(i);
float max = cs.getMaxValue(i);
val[i] = 0.5f * (max - min);
}
rgb = new float[]{0.5f, 0.5f, 0.5f};
cie = new float[]{0.5f, 0.5f, 0.5f};
}
示例2: bitsArrayHelper
import java.awt.color.ColorSpace; //导入方法依赖的package包/类
private static int[] bitsArrayHelper(int[] origBits,
int transferType,
ColorSpace colorSpace,
boolean hasAlpha) {
switch(transferType) {
case DataBuffer.TYPE_BYTE:
case DataBuffer.TYPE_USHORT:
case DataBuffer.TYPE_INT:
if (origBits != null) {
return origBits;
}
break;
default:
break;
}
int numBits = DataBuffer.getDataTypeSize(transferType);
int numComponents = colorSpace.getNumComponents();
if (hasAlpha) {
++numComponents;
}
int[] bits = new int[numComponents];
for (int i = 0; i < numComponents; i++) {
bits[i] = numBits;
}
return bits;
}
示例3: Color
import java.awt.color.ColorSpace; //导入方法依赖的package包/类
/**
* Creates a color in the specified <code>ColorSpace</code>
* with the color components specified in the <code>float</code>
* array and the specified alpha. The number of components is
* determined by the type of the <code>ColorSpace</code>. For
* example, RGB requires 3 components, but CMYK requires 4
* components.
* @param cspace the <code>ColorSpace</code> to be used to
* interpret the components
* @param components an arbitrary number of color components
* that is compatible with the <code>ColorSpace</code>
* @param alpha alpha value
* @throws IllegalArgumentException if any of the values in the
* <code>components</code> array or <code>alpha</code> is
* outside of the range 0.0 to 1.0
* @see #getComponents
* @see #getColorComponents
*/
public Color(ColorSpace cspace, float components[], float alpha) {
boolean rangeError = false;
String badComponentString = "";
int n = cspace.getNumComponents();
fvalue = new float[n];
for (int i = 0; i < n; i++) {
if (components[i] < 0.0 || components[i] > 1.0) {
rangeError = true;
badComponentString = badComponentString + "Component " + i
+ " ";
} else {
fvalue[i] = components[i];
}
}
if (alpha < 0.0 || alpha > 1.0) {
rangeError = true;
badComponentString = badComponentString + "Alpha";
} else {
falpha = alpha;
}
if (rangeError) {
throw new IllegalArgumentException(
"Color parameter outside of expected range: " +
badComponentString);
}
frgbvalue = cspace.toRGB(fvalue);
cs = cspace;
value = ((((int)(falpha*255)) & 0xFF) << 24) |
((((int)(frgbvalue[0]*255)) & 0xFF) << 16) |
((((int)(frgbvalue[1]*255)) & 0xFF) << 8) |
((((int)(frgbvalue[2]*255)) & 0xFF) << 0);
}
示例4: bitsHelper
import java.awt.color.ColorSpace; //导入方法依赖的package包/类
private static int bitsHelper(int transferType,
ColorSpace colorSpace,
boolean hasAlpha) {
int numBits = DataBuffer.getDataTypeSize(transferType);
int numComponents = colorSpace.getNumComponents();
if (hasAlpha) {
++numComponents;
}
return numBits * numComponents;
}
示例5: createCompatibleDestRaster
import java.awt.color.ColorSpace; //导入方法依赖的package包/类
/**
* This method creates a compatible Raster, given a source raster, colorspace,
* alpha value, and transfer type.
*
* @param src The source raster.
* @param cs The ColorSpace to use.
* @param hasAlpha Whether the raster should include a component for an alpha.
* @param transferType The size of a single data element.
* @return A compatible WritableRaster.
*/
private WritableRaster createCompatibleDestRaster(Raster src, ColorSpace cs,
boolean hasAlpha,
int transferType)
{
// The use of a PixelInterleavedSampleModel weas determined using mauve
// tests, based on the reference implementation
int numComponents = cs.getNumComponents();
if (hasAlpha)
numComponents++;
int[] offsets = new int[numComponents];
for (int i = 0; i < offsets.length; i++)
offsets[i] = i;
DataBuffer db = Buffers.createBuffer(transferType,
src.getWidth() * src.getHeight() * numComponents,
1);
return new WritableRaster(new PixelInterleavedSampleModel(transferType,
src.getWidth(),
src.getHeight(),
numComponents,
numComponents * src.getWidth(),
offsets),
db, new Point(src.getMinX(), src.getMinY()));
}
示例6: Color
import java.awt.color.ColorSpace; //导入方法依赖的package包/类
/**
* Creates a color in the specified {@code ColorSpace}
* with the color components specified in the {@code float}
* array and the specified alpha. The number of components is
* determined by the type of the {@code ColorSpace}. For
* example, RGB requires 3 components, but CMYK requires 4
* components.
* @param cspace the {@code ColorSpace} to be used to
* interpret the components
* @param components an arbitrary number of color components
* that is compatible with the {@code ColorSpace}
* @param alpha alpha value
* @throws IllegalArgumentException if any of the values in the
* {@code components} array or {@code alpha} is
* outside of the range 0.0 to 1.0
* @see #getComponents
* @see #getColorComponents
*/
public Color(ColorSpace cspace, float components[], float alpha) {
boolean rangeError = false;
String badComponentString = "";
int n = cspace.getNumComponents();
fvalue = new float[n];
for (int i = 0; i < n; i++) {
if (components[i] < 0.0 || components[i] > 1.0) {
rangeError = true;
badComponentString = badComponentString + "Component " + i
+ " ";
} else {
fvalue[i] = components[i];
}
}
if (alpha < 0.0 || alpha > 1.0) {
rangeError = true;
badComponentString = badComponentString + "Alpha";
} else {
falpha = alpha;
}
if (rangeError) {
throw new IllegalArgumentException(
"Color parameter outside of expected range: " +
badComponentString);
}
frgbvalue = cspace.toRGB(fvalue);
cs = cspace;
value = ((((int)(falpha*255)) & 0xFF) << 24) |
((((int)(frgbvalue[0]*255)) & 0xFF) << 16) |
((((int)(frgbvalue[1]*255)) & 0xFF) << 8) |
((((int)(frgbvalue[2]*255)) & 0xFF) << 0);
}
示例7: Interleaved
import java.awt.color.ColorSpace; //导入方法依赖的package包/类
public Interleaved(ColorSpace colorSpace,
int[] bandOffsets,
int dataType,
boolean hasAlpha,
boolean isAlphaPremultiplied) {
if (colorSpace == null) {
throw new IllegalArgumentException("colorSpace == null!");
}
if (bandOffsets == null) {
throw new IllegalArgumentException("bandOffsets == null!");
}
int numBands = colorSpace.getNumComponents() +
(hasAlpha ? 1 : 0);
if (bandOffsets.length != numBands) {
throw new IllegalArgumentException
("bandOffsets.length is wrong!");
}
if (dataType != DataBuffer.TYPE_BYTE &&
dataType != DataBuffer.TYPE_SHORT &&
dataType != DataBuffer.TYPE_USHORT &&
dataType != DataBuffer.TYPE_INT &&
dataType != DataBuffer.TYPE_FLOAT &&
dataType != DataBuffer.TYPE_DOUBLE) {
throw new IllegalArgumentException
("Bad value for dataType!");
}
this.colorSpace = colorSpace;
this.bandOffsets = (int[])bandOffsets.clone();
this.dataType = dataType;
this.hasAlpha = hasAlpha;
this.isAlphaPremultiplied = isAlphaPremultiplied;
this.colorModel =
ImageTypeSpecifier.createComponentCM(colorSpace,
bandOffsets.length,
dataType,
hasAlpha,
isAlphaPremultiplied);
int minBandOffset = bandOffsets[0];
int maxBandOffset = minBandOffset;
for (int i = 0; i < bandOffsets.length; i++) {
int offset = bandOffsets[i];
minBandOffset = Math.min(offset, minBandOffset);
maxBandOffset = Math.max(offset, maxBandOffset);
}
int pixelStride = maxBandOffset - minBandOffset + 1;
int w = 1;
int h = 1;
this.sampleModel =
new PixelInterleavedSampleModel(dataType,
w, h,
pixelStride,
w*pixelStride,
bandOffsets);
}
示例8: Banded
import java.awt.color.ColorSpace; //导入方法依赖的package包/类
public Banded(ColorSpace colorSpace,
int[] bankIndices,
int[] bandOffsets,
int dataType,
boolean hasAlpha,
boolean isAlphaPremultiplied) {
if (colorSpace == null) {
throw new IllegalArgumentException("colorSpace == null!");
}
if (bankIndices == null) {
throw new IllegalArgumentException("bankIndices == null!");
}
if (bandOffsets == null) {
throw new IllegalArgumentException("bandOffsets == null!");
}
if (bankIndices.length != bandOffsets.length) {
throw new IllegalArgumentException
("bankIndices.length != bandOffsets.length!");
}
if (dataType != DataBuffer.TYPE_BYTE &&
dataType != DataBuffer.TYPE_SHORT &&
dataType != DataBuffer.TYPE_USHORT &&
dataType != DataBuffer.TYPE_INT &&
dataType != DataBuffer.TYPE_FLOAT &&
dataType != DataBuffer.TYPE_DOUBLE) {
throw new IllegalArgumentException
("Bad value for dataType!");
}
int numBands = colorSpace.getNumComponents() +
(hasAlpha ? 1 : 0);
if (bandOffsets.length != numBands) {
throw new IllegalArgumentException
("bandOffsets.length is wrong!");
}
this.colorSpace = colorSpace;
this.bankIndices = (int[])bankIndices.clone();
this.bandOffsets = (int[])bandOffsets.clone();
this.dataType = dataType;
this.hasAlpha = hasAlpha;
this.isAlphaPremultiplied = isAlphaPremultiplied;
this.colorModel =
ImageTypeSpecifier.createComponentCM(colorSpace,
bankIndices.length,
dataType,
hasAlpha,
isAlphaPremultiplied);
int w = 1;
int h = 1;
this.sampleModel = new BandedSampleModel(dataType,
w, h,
w,
bankIndices,
bandOffsets);
}
示例9: Interleaved
import java.awt.color.ColorSpace; //导入方法依赖的package包/类
public Interleaved(ColorSpace colorSpace,
int[] bandOffsets,
int dataType,
boolean hasAlpha,
boolean isAlphaPremultiplied) {
if (colorSpace == null) {
throw new IllegalArgumentException("colorSpace == null!");
}
if (bandOffsets == null) {
throw new IllegalArgumentException("bandOffsets == null!");
}
int numBands = colorSpace.getNumComponents() +
(hasAlpha ? 1 : 0);
if (bandOffsets.length != numBands) {
throw new IllegalArgumentException
("bandOffsets.length is wrong!");
}
if (dataType != DataBuffer.TYPE_BYTE &&
dataType != DataBuffer.TYPE_SHORT &&
dataType != DataBuffer.TYPE_USHORT &&
dataType != DataBuffer.TYPE_INT &&
dataType != DataBuffer.TYPE_FLOAT &&
dataType != DataBuffer.TYPE_DOUBLE) {
throw new IllegalArgumentException
("Bad value for dataType!");
}
this.colorSpace = colorSpace;
this.bandOffsets = bandOffsets.clone();
this.dataType = dataType;
this.hasAlpha = hasAlpha;
this.isAlphaPremultiplied = isAlphaPremultiplied;
this.colorModel =
ImageTypeSpecifier.createComponentCM(colorSpace,
bandOffsets.length,
dataType,
hasAlpha,
isAlphaPremultiplied);
int minBandOffset = bandOffsets[0];
int maxBandOffset = minBandOffset;
for (int i = 0; i < bandOffsets.length; i++) {
int offset = bandOffsets[i];
minBandOffset = Math.min(offset, minBandOffset);
maxBandOffset = Math.max(offset, maxBandOffset);
}
int pixelStride = maxBandOffset - minBandOffset + 1;
int w = 1;
int h = 1;
this.sampleModel =
new PixelInterleavedSampleModel(dataType,
w, h,
pixelStride,
w*pixelStride,
bandOffsets);
}
示例10: Banded
import java.awt.color.ColorSpace; //导入方法依赖的package包/类
public Banded(ColorSpace colorSpace,
int[] bankIndices,
int[] bandOffsets,
int dataType,
boolean hasAlpha,
boolean isAlphaPremultiplied) {
if (colorSpace == null) {
throw new IllegalArgumentException("colorSpace == null!");
}
if (bankIndices == null) {
throw new IllegalArgumentException("bankIndices == null!");
}
if (bandOffsets == null) {
throw new IllegalArgumentException("bandOffsets == null!");
}
if (bankIndices.length != bandOffsets.length) {
throw new IllegalArgumentException
("bankIndices.length != bandOffsets.length!");
}
if (dataType != DataBuffer.TYPE_BYTE &&
dataType != DataBuffer.TYPE_SHORT &&
dataType != DataBuffer.TYPE_USHORT &&
dataType != DataBuffer.TYPE_INT &&
dataType != DataBuffer.TYPE_FLOAT &&
dataType != DataBuffer.TYPE_DOUBLE) {
throw new IllegalArgumentException
("Bad value for dataType!");
}
int numBands = colorSpace.getNumComponents() +
(hasAlpha ? 1 : 0);
if (bandOffsets.length != numBands) {
throw new IllegalArgumentException
("bandOffsets.length is wrong!");
}
this.colorSpace = colorSpace;
this.bankIndices = bankIndices.clone();
this.bandOffsets = bandOffsets.clone();
this.dataType = dataType;
this.hasAlpha = hasAlpha;
this.isAlphaPremultiplied = isAlphaPremultiplied;
this.colorModel =
ImageTypeSpecifier.createComponentCM(colorSpace,
bankIndices.length,
dataType,
hasAlpha,
isAlphaPremultiplied);
int w = 1;
int h = 1;
this.sampleModel = new BandedSampleModel(dataType,
w, h,
w,
bankIndices,
bandOffsets);
}