Java 类sun.awt.image.IntegerInterleavedRaster 实例源码

项目:BoofCV-master    文件:ConvertRaster.java   
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");
        }
    }
项目:BoofCV-master    文件:ConvertRaster.java   
public static void grayToBuffered(ImageInt16 src, IntegerInterleavedRaster dst) {
    final short[] 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 = (int) srcData[indexSrc++];

                dstData[indexDst++] = v << 16 | v << 8 | v;
            }
        }
    } else {
        throw new RuntimeException("Code more here");
    }
}
项目:BoofCV-master    文件:ConvertBufferedImage.java   
/**
 * 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;
}
项目:BoofCV-master    文件:ConvertBufferedImage.java   
/**
 * Converts the buffered image into an {@link boofcv.struct.image.ImageFloat32}.  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 ImageFloat32 convertFrom(BufferedImage src, ImageFloat32 dst) {
    if (dst != null) {
        if (src.getWidth() != dst.getWidth() || src.getHeight() != dst.getHeight()) {
            throw new IllegalArgumentException("image dimension are different");
        }
    } else {
        dst = new ImageFloat32(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;
}
项目:BoofCV-master    文件:ConvertBufferedImage.java   
/**
 * 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;
}
项目:BoofCV-master    文件:ConvertBufferedImage.java   
/**
 * Converts a {@link boofcv.struct.image.ImageInt16} 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(ImageInt16 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 if( dst.getType() == BufferedImage.TYPE_USHORT_GRAY ) {
            ConvertRaster.grayToBuffered(src, (ShortInterleavedRaster) 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;
}
项目:BoofCV-master    文件:ConvertBufferedImage.java   
/**
 * Converts the buffered image into an {@link boofcv.struct.image.ImageFloat32}.  If the buffered image
 * has multiple channels the intensities of each channel are averaged together.  The floating
 * point image is assumed to be between 0 and 255.
 *
 * @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(ImageFloat32 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;
}
项目:BoofCV-master    文件:ConvertBufferedImage.java   
/**
 * 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;
}
项目:BoofCV-master    文件:ConvertBufferedImage.java   
/**
 * 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;
}
项目:BoofCV-master    文件:TestConvertRaster.java   
/**
 * 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;
}
项目:BoofCV-master    文件:VisualizeBinaryData.java   
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;
    }
项目:OpenJSharp    文件:TexturePaintContext.java   
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);
}
项目:OpenJSharp    文件:TexturePaintContext.java   
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;
}
项目:OpenJSharp    文件:TexturePaintContext.java   
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;
}
项目:OpenJSharp    文件:TexturePaintContext.java   
public WritableRaster makeRaster(int w, int h) {
    // Note that we do not pass srcRas to makeRaster since it
    // is a Byte Raster and this colorModel needs an Int Raster
    WritableRaster ras = makeRaster(colorModel, null, w, h);
    IntegerInterleavedRaster iiRas = (IntegerInterleavedRaster) ras;
    outData = iiRas.getDataStorage();
    outSpan = iiRas.getScanlineStride();
    outOff = iiRas.getDataOffset(0);
    return ras;
}
项目:jdk8u-jdk    文件:TexturePaintContext.java   
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);
}
项目:jdk8u-jdk    文件:TexturePaintContext.java   
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;
}
项目:jdk8u-jdk    文件:TexturePaintContext.java   
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;
}
项目:jdk8u-jdk    文件:TexturePaintContext.java   
public WritableRaster makeRaster(int w, int h) {
    // Note that we do not pass srcRas to makeRaster since it
    // is a Byte Raster and this colorModel needs an Int Raster
    WritableRaster ras = makeRaster(colorModel, null, w, h);
    IntegerInterleavedRaster iiRas = (IntegerInterleavedRaster) ras;
    outData = iiRas.getDataStorage();
    outSpan = iiRas.getScanlineStride();
    outOff = iiRas.getDataOffset(0);
    return ras;
}
项目:openjdk-jdk10    文件:TexturePaintContext.java   
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);
}
项目:openjdk-jdk10    文件:TexturePaintContext.java   
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;
}
项目:openjdk-jdk10    文件:TexturePaintContext.java   
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;
}
项目:openjdk-jdk10    文件:TexturePaintContext.java   
public WritableRaster makeRaster(int w, int h) {
    // Note that we do not pass srcRas to makeRaster since it
    // is a Byte Raster and this colorModel needs an Int Raster
    WritableRaster ras = makeRaster(colorModel, null, w, h);
    IntegerInterleavedRaster iiRas = (IntegerInterleavedRaster) ras;
    outData = iiRas.getDataStorage();
    outSpan = iiRas.getScanlineStride();
    outOff = iiRas.getDataOffset(0);
    return ras;
}
项目:openjdk9    文件:TexturePaintContext.java   
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);
}
项目:openjdk9    文件:TexturePaintContext.java   
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;
}
项目:openjdk9    文件:TexturePaintContext.java   
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;
}
项目:openjdk9    文件:TexturePaintContext.java   
public WritableRaster makeRaster(int w, int h) {
    // Note that we do not pass srcRas to makeRaster since it
    // is a Byte Raster and this colorModel needs an Int Raster
    WritableRaster ras = makeRaster(colorModel, null, w, h);
    IntegerInterleavedRaster iiRas = (IntegerInterleavedRaster) ras;
    outData = iiRas.getDataStorage();
    outSpan = iiRas.getScanlineStride();
    outOff = iiRas.getDataOffset(0);
    return ras;
}
项目:Java8CN    文件:TexturePaintContext.java   
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);
}
项目:Java8CN    文件:TexturePaintContext.java   
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;
}
项目:Java8CN    文件:TexturePaintContext.java   
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;
}
项目:Java8CN    文件:TexturePaintContext.java   
public WritableRaster makeRaster(int w, int h) {
    // Note that we do not pass srcRas to makeRaster since it
    // is a Byte Raster and this colorModel needs an Int Raster
    WritableRaster ras = makeRaster(colorModel, null, w, h);
    IntegerInterleavedRaster iiRas = (IntegerInterleavedRaster) ras;
    outData = iiRas.getDataStorage();
    outSpan = iiRas.getScanlineStride();
    outOff = iiRas.getDataOffset(0);
    return ras;
}
项目:Java8CN    文件:Raster.java   
/**
 * 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);
    }
}
项目:jdk8u_jdk    文件:TexturePaintContext.java   
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);
}
项目:jdk8u_jdk    文件:TexturePaintContext.java   
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;
}
项目:jdk8u_jdk    文件:TexturePaintContext.java   
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;
}
项目:jdk8u_jdk    文件:TexturePaintContext.java   
public WritableRaster makeRaster(int w, int h) {
    // Note that we do not pass srcRas to makeRaster since it
    // is a Byte Raster and this colorModel needs an Int Raster
    WritableRaster ras = makeRaster(colorModel, null, w, h);
    IntegerInterleavedRaster iiRas = (IntegerInterleavedRaster) ras;
    outData = iiRas.getDataStorage();
    outSpan = iiRas.getScanlineStride();
    outOff = iiRas.getDataOffset(0);
    return ras;
}
项目:jdk8u_jdk    文件:Raster.java   
/**
 * 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);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:TexturePaintContext.java   
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);
}
项目:lookaside_java-1.8.0-openjdk    文件:TexturePaintContext.java   
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;
}
项目:lookaside_java-1.8.0-openjdk    文件:TexturePaintContext.java   
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;
}