/**
* Create a grayscale image type specifier, given the number of
* bits, data type and whether or not the data is signed.
*
* @param bits the number of bits used to specify a greyscale value
* @param dataType a DataBuffer type constant
* @param isSigned true if this type specifier should support
* negative values, false otherwise
*
* @return a greyscal image type specifier
*
* @exception IllegalArgumentException if bits is not 1, 2, 4, 8 or
* 16
* @exception IllegalArgumentException if dataType is not
* DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
* DataBuffer.TYPE_USHORT
* @exception if bits is larger than the number of bits in the given
* data type
*/
public static ImageTypeSpecifier createGrayscale (int bits, int dataType,
boolean isSigned,
boolean isAlphaPremultiplied)
{
if (bits != 1 && bits != 2 && bits != 4 && bits != 8 && bits != 16)
throw new IllegalArgumentException ("invalid bit size");
if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_SHORT
&& dataType != DataBuffer.TYPE_USHORT)
throw new IllegalArgumentException ("invalid data type");
if (dataType == DataBuffer.TYPE_BYTE && bits > 8)
throw new IllegalArgumentException ("number of bits too large for data type");
// FIXME: this is probably wrong:
return new ImageTypeSpecifier (new DirectColorModel (bits, 0xff, 0x0,
0x0, 0xff),
new MultiPixelPackedSampleModel (dataType,
1, 1,
bits));
}
ImageTypeSpecifier.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:javify
作者:
评论列表
文章目录