本文整理汇总了Java中java.awt.image.MultiPixelPackedSampleModel类的典型用法代码示例。如果您正苦于以下问题:Java MultiPixelPackedSampleModel类的具体用法?Java MultiPixelPackedSampleModel怎么用?Java MultiPixelPackedSampleModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MultiPixelPackedSampleModel类属于java.awt.image包,在下文中一共展示了MultiPixelPackedSampleModel类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getElementSize
import java.awt.image.MultiPixelPackedSampleModel; //导入依赖的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: createGrayscale
import java.awt.image.MultiPixelPackedSampleModel; //导入依赖的package包/类
/**
* 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));
}
示例3: decode
import java.awt.image.MultiPixelPackedSampleModel; //导入依赖的package包/类
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
IndexColorModel palette = readPalette(in);
skipToImage(in);
Dimension d = infoHeader.getSize();
int h = (int)d.getHeight();
int w = (int)d.getWidth();
byte[] data = uncompress(w, h, in);
SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
w, h, 4);
DataBuffer db = new DataBufferByte(data, w*h, 0);
WritableRaster raster = Raster.createWritableRaster(sm, db, null);
return new BufferedImage(palette, raster, false, null);
}
示例4: decode
import java.awt.image.MultiPixelPackedSampleModel; //导入依赖的package包/类
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
IndexColorModel palette = readPalette(in);
skipToImage(in);
Dimension d = infoHeader.getSize();
int h = (int)d.getHeight();
int w = (int)d.getWidth();
byte[] data = uncompress(w, h, in);
SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
w, h, 4);
DataBuffer db = new DataBufferByte(data, w*h, 0);
WritableRaster raster = Raster.createWritableRaster(sm, db, null);
return new BufferedImage(palette, raster, false, null);
}
示例5: create
import java.awt.image.MultiPixelPackedSampleModel; //导入依赖的package包/类
/**
* Creates a Tranpose operation.
*/
public RenderedImage create(ParameterBlock paramBlock,
RenderingHints renderHints) {
// Get ImageLayout from renderHints if any.
ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);
RenderedImage source = paramBlock.getRenderedSource(0);
EnumeratedParameter type =
(EnumeratedParameter)paramBlock.getObjectParameter(0);
SampleModel sm = source.getSampleModel();
if ((sm instanceof MultiPixelPackedSampleModel) &&
(sm.getSampleSize(0) == 1) &&
(sm.getDataType() == DataBuffer.TYPE_BYTE ||
sm.getDataType() == DataBuffer.TYPE_USHORT ||
sm.getDataType() == DataBuffer.TYPE_INT)) {
return new TransposeBinaryOpImage(source, renderHints, layout,
type.getValue());
} else {
return new TransposeOpImage(source, renderHints, layout,
type.getValue());
}
}
示例6: createBinaryImage
import java.awt.image.MultiPixelPackedSampleModel; //导入依赖的package包/类
/**
* Create a binary PlanarImage of the size/bounds specified by
* the rectangle.
*/
private static PlanarImage createBinaryImage(Rectangle r) {
if ((r.x == 0) && (r.y == 0)) {
BufferedImage bi =
new BufferedImage(r.width, r.height,
BufferedImage.TYPE_BYTE_BINARY);
return PlanarImage.wrapRenderedImage(bi);
} else {
SampleModel sm =
new MultiPixelPackedSampleModel(
DataBuffer.TYPE_BYTE, r.width, r.height, 1);
// Create a TiledImage into which to write.
return new TiledImage(r.x, r.y, r.width, r.height, r.x, r.y,
sm, PlanarImage.createColorModel(sm));
}
}
示例7: getElementSize
import java.awt.image.MultiPixelPackedSampleModel; //导入依赖的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();
}
示例8: create
import java.awt.image.MultiPixelPackedSampleModel; //导入依赖的package包/类
/** Creates an BinarizeOpImage with a given ParameterBlock */
public RenderedImage create(ParameterBlock paramBlock,
RenderingHints renderingHints)
{
RenderedImage img = paramBlock.getRenderedSource(0);
ImageLayout il = new ImageLayout(img);
ColorModel cm = new IndexColorModel(1, 2, bwColors, bwColors, bwColors);
SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
img.getWidth(),
img.getHeight(),
1);
il.setColorModel(cm);
il.setSampleModel(sm);
return new BinarizeOpImage(paramBlock.getRenderedSource(0),
renderingHints,
il,
(Integer)paramBlock.getObjectParameter(0));
}
示例9: convert
import java.awt.image.MultiPixelPackedSampleModel; //导入依赖的package包/类
@Override
public SampleModel convert(FieldAccessor fa, Instance instance) throws FieldAccessor.InvalidFieldException {
int width = fa.getInt(instance, "width"); // NOI18N
int height = fa.getInt(instance, "height"); // NOI18N
int dataType = fa.getInt(instance, "dataType"); // NOI18N
int scanlineStride = fa.getInt(instance, "scanlineStride"); // NOI18N
int numberOfBits = fa.getInt(instance, "numberOfBits"); // NOI18N
int dataBitOffset = fa.getInt(instance, "dataBitOffset"); // NOI18N
return new MultiPixelPackedSampleModel(dataType, width, height, numberOfBits, scanlineStride, dataBitOffset);
}
示例10: canEncodeImage
import java.awt.image.MultiPixelPackedSampleModel; //导入依赖的package包/类
public boolean canEncodeImage(ImageTypeSpecifier type) {
SampleModel sm = type.getSampleModel();
if (!(sm instanceof MultiPixelPackedSampleModel))
return false;
if (sm.getSampleSize(0) != 1)
return false;
return true;
}
示例11: main
import java.awt.image.MultiPixelPackedSampleModel; //导入依赖的package包/类
public static void main(String[] args) {
Vector<Class<? extends SampleModel>> classes = new Vector<Class<? extends SampleModel>>();
classes.add(ComponentSampleModel.class);
classes.add(MultiPixelPackedSampleModel.class);
classes.add(SinglePixelPackedSampleModel.class);
classes.add(BandedSampleModel.class);
classes.add(PixelInterleavedSampleModel.class);
for (Class<? extends SampleModel> c : classes) {
doTest(c);
}
}
示例12: createIndexed
import java.awt.image.MultiPixelPackedSampleModel; //导入依赖的package包/类
/**
* Return an image type specifier for an image that uses an indexed
* colour model where each colour value has the specified number of
* bits and type and where the colour tables are those given.
*
* @param redLUT the red index values
* @param greenLUT the green index values
* @param blueLUT the blue index values
* @param alphaLUT the alpha index values
* @param bits the number of bits per index value
* @param dataType the type of each index value
*
* @return an indexed image type specifier
*
* @exception IllegalArgumentException if any of the colour arrays,
* not including alphaLUT, is null
* @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 createIndexed (byte[] redLUT,
byte[] greenLUT,
byte[] blueLUT,
byte[] alphaLUT,
int bits,
int dataType)
{
if (redLUT == null || greenLUT == null || blueLUT == null)
throw new IllegalArgumentException ("null colour table");
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 IndexColorModel (bits, redLUT.length,
redLUT, greenLUT, blueLUT,
alphaLUT),
new MultiPixelPackedSampleModel (dataType,
1, 1,
bits));
}
示例13: decode
import java.awt.image.MultiPixelPackedSampleModel; //导入依赖的package包/类
public BufferedImage decode(ImageInputStream in) throws IOException, BMPException {
IndexColorModel palette = readPalette(in);
skipToImage(in);
Dimension d = infoHeader.getSize();
int h = (int)d.getHeight();
int w = (int)d.getWidth();
int size = (w*h) >> 1;
// Scanline padded to dword offsets
int wbytes = (w + (w & 1)) >> 1;
int scansize = ((wbytes & 3) != 0)? (wbytes + 4 - (wbytes&3)) : wbytes;
byte[] data = new byte[wbytes*h];
for(int y=h-1;y>=0;y--){
byte[] scanline = new byte[scansize];
if(in.read(scanline) != scansize)
throw new IOException("Couldn't read image data.");
for(int x=0;x<wbytes;x++)
data[x + y*wbytes] = scanline[x];
}
SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
w, h, 4);
DataBuffer db = new DataBufferByte(data, w*h, 0);
WritableRaster raster = Raster.createWritableRaster(sm, db, null);
return new BufferedImage(palette, raster, false, null);
}
示例14: createIndexed
import java.awt.image.MultiPixelPackedSampleModel; //导入依赖的package包/类
/**
* Return an image type specifier for an image that uses an indexed
* colour model where each colour value has the specified number of
* bits and type and where the colour tables are those given.
*
* @param redLUT the red index values
* @param greenLUT the green index values
* @param blueLUT the blue index values
* @param alphaLUT the alpha index values
* @param bits the number of bits per index value
* @param dataType the type of each index value
*
* @return an indexed image type specifier
*
* @exception IllegalArgumentException if any of the colour arrays,
* not including alphaLUT, is null
* @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 createIndexed (byte[] redLUT,
byte[] greenLUT,
byte[] blueLUT,
byte[] alphaLUT,
int bits,
int dataType)
{
if (redLUT == null || greenLUT == null || blueLUT == null)
throw new IllegalArgumentException ("null colour table");
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 IndexColorModel (bits, redLUT.length,
redLUT, greenLUT, blueLUT,
alphaLUT),
new MultiPixelPackedSampleModel (dataType,
1, 1,
bits));
}