本文整理汇总了Java中sun.awt.image.IntegerInterleavedRaster类的典型用法代码示例。如果您正苦于以下问题:Java IntegerInterleavedRaster类的具体用法?Java IntegerInterleavedRaster怎么用?Java IntegerInterleavedRaster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntegerInterleavedRaster类属于sun.awt.image包,在下文中一共展示了IntegerInterleavedRaster类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: grayToBuffered
import sun.awt.image.IntegerInterleavedRaster; //导入依赖的package包/类
public static void grayToBuffered(ImageUInt8 src, IntegerInterleavedRaster dst) {
final byte[] srcData = src.data;
final int[] dstData = dst.getDataStorage();
final int numBands = dst.getNumBands();
if (numBands == 3) {
int indexDst = 0;
for (int y = 0; y < src.height; y++) {
int indexSrc = src.startIndex + y * src.stride;
for (int x = 0; x < src.width; x++) {
int v = srcData[indexSrc++] & 0xFF;
dstData[indexDst++] = v << 16 | v << 8 | v;
}
}
} else {
throw new RuntimeException("Code more here");
}
}
示例2: convertFrom
import sun.awt.image.IntegerInterleavedRaster; //导入依赖的package包/类
/**
* Converts the buffered image into an {@link boofcv.struct.image.ImageUInt8}. If the buffered image
* has multiple channels the intensities of each channel are averaged together.
*
* @param src Input image.
* @param dst Where the converted image is written to. If null a new unsigned image is created.
* @return Converted image.
*/
public static ImageUInt8 convertFrom(BufferedImage src, ImageUInt8 dst) {
if (dst != null) {
if (src.getWidth() != dst.getWidth() || src.getHeight() != dst.getHeight()) {
throw new IllegalArgumentException("image dimension are different");
}
} else {
dst = new ImageUInt8(src.getWidth(), src.getHeight());
}
try {
if (src.getRaster() instanceof ByteInterleavedRaster &&
src.getType() != BufferedImage.TYPE_BYTE_INDEXED ) {
ConvertRaster.bufferedToGray((ByteInterleavedRaster) src.getRaster(), dst);
} else if (src.getRaster() instanceof IntegerInterleavedRaster) {
ConvertRaster.bufferedToGray((IntegerInterleavedRaster) src.getRaster(), dst);
} else {
ConvertRaster.bufferedToGray(src, dst);
}
} catch( java.security.AccessControlException e) {
// Applets don't allow access to the raster()
ConvertRaster.bufferedToGray(src, dst);
}
return dst;
}
示例3: convertTo
import sun.awt.image.IntegerInterleavedRaster; //导入依赖的package包/类
/**
* Converts a {@link boofcv.struct.image.ImageUInt8} into a BufferedImage. If the buffered image
* has multiple channels the intensities of each channel are averaged together.
*
* @param src Input image.
* @param dst Where the converted image is written to. If null a new image is created.
* @return Converted image.
*/
public static BufferedImage convertTo(ImageUInt8 src, BufferedImage dst) {
dst = checkInputs(src, dst);
try {
if (dst.getRaster() instanceof ByteInterleavedRaster &&
dst.getType() != BufferedImage.TYPE_BYTE_INDEXED ) {
ConvertRaster.grayToBuffered(src, (ByteInterleavedRaster) dst.getRaster());
} else if (dst.getRaster() instanceof IntegerInterleavedRaster) {
ConvertRaster.grayToBuffered(src, (IntegerInterleavedRaster) dst.getRaster());
} else {
ConvertRaster.grayToBuffered(src, dst);
}
// hack so that it knows the buffer has been modified
dst.setRGB(0,0,dst.getRGB(0,0));
} catch( java.security.AccessControlException e) {
ConvertRaster.grayToBuffered(src, dst);
}
return dst;
}
示例4: convertTo_U8
import sun.awt.image.IntegerInterleavedRaster; //导入依赖的package包/类
/**
* Converts a {@link boofcv.struct.image.ImageUInt8} into a BufferedImage. If the buffered image
* has multiple channels the intensities of each channel are averaged together.
*
* @param src Input image.
* @param dst Where the converted image is written to. If null a new image is created.
* @return Converted image.
*/
public static BufferedImage convertTo_U8(MultiSpectral<ImageUInt8> src, BufferedImage dst) {
dst = checkInputs(src, dst);
try {
if (dst.getRaster() instanceof ByteInterleavedRaster &&
dst.getType() != BufferedImage.TYPE_BYTE_INDEXED ) {
ConvertRaster.multToBuffered_U8(src, (ByteInterleavedRaster) dst.getRaster());
} else if (dst.getRaster() instanceof IntegerInterleavedRaster) {
ConvertRaster.multToBuffered_U8(src, (IntegerInterleavedRaster) dst.getRaster());
} else {
ConvertRaster.multToBuffered_U8(src, dst);
}
// hack so that it knows the buffer has been modified
dst.setRGB(0,0,dst.getRGB(0,0));
} catch( java.security.AccessControlException e) {
ConvertRaster.multToBuffered_U8(src, dst);
}
return dst;
}
示例5: convertTo_F32
import sun.awt.image.IntegerInterleavedRaster; //导入依赖的package包/类
/**
* Converts a {@link boofcv.struct.image.ImageUInt8} into a BufferedImage. If the buffered image
* has multiple channels the intensities of each channel are averaged together.
*
* @param src Input image.
* @param dst Where the converted image is written to. If null a new image is created.
* @return Converted image.
*/
public static BufferedImage convertTo_F32(MultiSpectral<ImageFloat32> src, BufferedImage dst) {
dst = checkInputs(src, dst);
try {
if (dst.getRaster() instanceof ByteInterleavedRaster &&
dst.getType() != BufferedImage.TYPE_BYTE_INDEXED ) {
ConvertRaster.multToBuffered_F32(src, (ByteInterleavedRaster) dst.getRaster());
} else if (dst.getRaster() instanceof IntegerInterleavedRaster) {
ConvertRaster.multToBuffered_F32(src, (IntegerInterleavedRaster) dst.getRaster());
} else {
ConvertRaster.multToBuffered_F32(src, dst);
}
// hack so that it knows the buffer has been modified
dst.setRGB(0,0,dst.getRGB(0,0));
} catch( java.security.AccessControlException e) {
ConvertRaster.multToBuffered_F32(src, dst);
}
return dst;
}
示例6: createBufferedTestImages
import sun.awt.image.IntegerInterleavedRaster; //导入依赖的package包/类
/**
* Creates a set of test BufferedImages with the appropriate rasters and number of bytes/channels.
*/
private BufferedImage[] createBufferedTestImages(Class<?> paramType) {
BufferedImage[] input;
if (paramType == ByteInterleavedRaster.class) {
// the code is handled different when a different number of channels is used
input = new BufferedImage[]{
createByteBuff(imgWidth, imgHeight, 4, rand),
createByteBuff(imgWidth, imgHeight, 3, rand),
createByteBuff(imgWidth, imgHeight, 1, rand)};
} else if (paramType == IntegerInterleavedRaster.class) {
input = new BufferedImage[]{createIntBuff(imgWidth, imgHeight, rand)};
} else if( paramType == ShortInterleavedRaster.class ) {
input = new BufferedImage[]{createShortBuff(imgWidth, imgHeight, rand)};
} else if (paramType == BufferedImage.class) {
// just pick an arbitrary image type here
input = new BufferedImage[]{createIntBuff(imgWidth, imgHeight, rand)};
} else {
throw new RuntimeException("Unknown raster type: " + paramType.getSimpleName());
}
return input;
}
示例7: renderLabeled
import sun.awt.image.IntegerInterleavedRaster; //导入依赖的package包/类
public static BufferedImage renderLabeled(ImageSInt32 labelImage, int colors[], BufferedImage out) {
if( out == null ) {
out = new BufferedImage(labelImage.getWidth(),labelImage.getHeight(),BufferedImage.TYPE_INT_RGB);
}
try {
if( out.getRaster() instanceof IntegerInterleavedRaster) {
renderLabeled(labelImage, colors, (IntegerInterleavedRaster)out.getRaster());
} else {
_renderLabeled(labelImage, out, colors);
}
} catch( SecurityException e ) {
_renderLabeled(labelImage, out, colors);
}
return out;
}
示例8: getContext
import sun.awt.image.IntegerInterleavedRaster; //导入依赖的package包/类
public static PaintContext getContext(BufferedImage bufImg,
AffineTransform xform,
RenderingHints hints,
Rectangle devBounds) {
WritableRaster raster = bufImg.getRaster();
ColorModel cm = bufImg.getColorModel();
int maxw = devBounds.width;
Object val = hints.get(RenderingHints.KEY_INTERPOLATION);
boolean filter =
(val == null
? (hints.get(RenderingHints.KEY_RENDERING) == RenderingHints.VALUE_RENDER_QUALITY)
: (val != RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR));
if (raster instanceof IntegerInterleavedRaster &&
(!filter || isFilterableDCM(cm)))
{
IntegerInterleavedRaster iir = (IntegerInterleavedRaster) raster;
if (iir.getNumDataElements() == 1 && iir.getPixelStride() == 1) {
return new Int(iir, cm, xform, maxw, filter);
}
} else if (raster instanceof ByteInterleavedRaster) {
ByteInterleavedRaster bir = (ByteInterleavedRaster) raster;
if (bir.getNumDataElements() == 1 && bir.getPixelStride() == 1) {
if (filter) {
if (isFilterableICM(cm)) {
return new ByteFilter(bir, cm, xform, maxw);
}
} else {
return new Byte(bir, cm, xform, maxw);
}
}
}
return new Any(raster, cm, xform, maxw, filter);
}
示例9: Int
import sun.awt.image.IntegerInterleavedRaster; //导入依赖的package包/类
public Int(IntegerInterleavedRaster srcRas, ColorModel cm,
AffineTransform xform, int maxw, boolean filter)
{
super(cm, xform, srcRas.getWidth(), srcRas.getHeight(), maxw);
this.srcRas = srcRas;
this.inData = srcRas.getDataStorage();
this.inSpan = srcRas.getScanlineStride();
this.inOff = srcRas.getDataOffset(0);
this.filter = filter;
}
示例10: makeRaster
import sun.awt.image.IntegerInterleavedRaster; //导入依赖的package包/类
public WritableRaster makeRaster(int w, int h) {
WritableRaster ras = makeRaster(colorModel, srcRas, w, h);
IntegerInterleavedRaster iiRas = (IntegerInterleavedRaster) ras;
outData = iiRas.getDataStorage();
outSpan = iiRas.getScanlineStride();
outOff = iiRas.getDataOffset(0);
return ras;
}
示例11: createPackedRaster
import sun.awt.image.IntegerInterleavedRaster; //导入依赖的package包/类
/**
* Creates a Raster based on a SinglePixelPackedSampleModel with
* the specified DataBuffer, width, height, scanline stride, and
* band masks. The number of bands is inferred from bandMasks.length.
* The upper left corner of the Raster is given by
* the location argument. If location is null, (0, 0) will be used.
* @param dataBuffer the <code>DataBuffer</code> that contains the
* image data
* @param w the width in pixels of the image data
* @param h the height in pixels of the image data
* @param scanlineStride the line stride of the image data
* @param bandMasks an array containing an entry for each band
* @param location the upper-left corner of the <code>Raster</code>
* @return a WritableRaster object with the specified
* <code>DataBuffer</code>, width, height, scanline stride,
* and band masks.
* @throws RasterFormatException if <code>w</code> or <code>h</code>
* is less than or equal to zero, or computing either
* <code>location.x + w</code> or
* <code>location.y + h</code> results in integer
* overflow
* @throws IllegalArgumentException if <code>dataType</code> is not
* one of the supported data types, which are
* <code>DataBuffer.TYPE_BYTE</code>,
* <code>DataBuffer.TYPE_USHORT</code>
* or <code>DataBuffer.TYPE_INT</code>
* @throws RasterFormatException if <code>dataBuffer</code> has more
* than one bank.
* @throws NullPointerException if <code>dataBuffer</code> is null
*/
public static WritableRaster createPackedRaster(DataBuffer dataBuffer,
int w, int h,
int scanlineStride,
int bandMasks[],
Point location) {
if (dataBuffer == null) {
throw new NullPointerException("DataBuffer cannot be null");
}
if (location == null) {
location = new Point(0,0);
}
int dataType = dataBuffer.getDataType();
SinglePixelPackedSampleModel sppsm =
new SinglePixelPackedSampleModel(dataType, w, h, scanlineStride,
bandMasks);
switch(dataType) {
case DataBuffer.TYPE_BYTE:
return new ByteInterleavedRaster(sppsm, dataBuffer, location);
case DataBuffer.TYPE_USHORT:
return new ShortInterleavedRaster(sppsm, dataBuffer, location);
case DataBuffer.TYPE_INT:
return new IntegerInterleavedRaster(sppsm, dataBuffer, location);
default:
throw new IllegalArgumentException("Unsupported data type " +
dataType);
}
}