java.awt.image.Raster#createCompatibleWritableRaster()源码实例Demo

下面列出了java.awt.image.Raster#createCompatibleWritableRaster() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk8u_jdk   文件: TexturePaintContext.java
synchronized static WritableRaster makeByteRaster(Raster srcRas,
                                                  int w, int h)
{
    if (byteRasRef != null) {
        WritableRaster wr = (WritableRaster) byteRasRef.get();
        if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) {
            byteRasRef = null;
            return wr;
        }
    }
    // If we are going to cache this Raster, make it non-tiny
    if (w <= 32 && h <= 32) {
        w = h = 32;
    }
    return srcRas.createCompatibleWritableRaster(w, h);
}
 
源代码2 项目: hottub   文件: TexturePaintContext.java
synchronized static WritableRaster makeByteRaster(Raster srcRas,
                                                  int w, int h)
{
    if (byteRasRef != null) {
        WritableRaster wr = (WritableRaster) byteRasRef.get();
        if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) {
            byteRasRef = null;
            return wr;
        }
    }
    // If we are going to cache this Raster, make it non-tiny
    if (w <= 32 && h <= 32) {
        w = h = 32;
    }
    return srcRas.createCompatibleWritableRaster(w, h);
}
 
源代码3 项目: jdk8u-jdk   文件: TexturePaintContext.java
synchronized static WritableRaster makeByteRaster(Raster srcRas,
                                                  int w, int h)
{
    if (byteRasRef != null) {
        WritableRaster wr = (WritableRaster) byteRasRef.get();
        if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) {
            byteRasRef = null;
            return wr;
        }
    }
    // If we are going to cache this Raster, make it non-tiny
    if (w <= 32 && h <= 32) {
        w = h = 32;
    }
    return srcRas.createCompatibleWritableRaster(w, h);
}
 
源代码4 项目: jdk8u60   文件: TexturePaintContext.java
synchronized static WritableRaster makeByteRaster(Raster srcRas,
                                                  int w, int h)
{
    if (byteRasRef != null) {
        WritableRaster wr = (WritableRaster) byteRasRef.get();
        if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) {
            byteRasRef = null;
            return wr;
        }
    }
    // If we are going to cache this Raster, make it non-tiny
    if (w <= 32 && h <= 32) {
        w = h = 32;
    }
    return srcRas.createCompatibleWritableRaster(w, h);
}
 
源代码5 项目: JDKSourceCode1.8   文件: TexturePaintContext.java
synchronized static WritableRaster makeByteRaster(Raster srcRas,
                                                  int w, int h)
{
    if (byteRasRef != null) {
        WritableRaster wr = (WritableRaster) byteRasRef.get();
        if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) {
            byteRasRef = null;
            return wr;
        }
    }
    // If we are going to cache this Raster, make it non-tiny
    if (w <= 32 && h <= 32) {
        w = h = 32;
    }
    return srcRas.createCompatibleWritableRaster(w, h);
}
 
源代码6 项目: jdk-1.7-annotated   文件: TexturePaintContext.java
synchronized static WritableRaster makeByteRaster(Raster srcRas,
                                                  int w, int h)
{
    if (byteRasRef != null) {
        WritableRaster wr = (WritableRaster) byteRasRef.get();
        if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) {
            byteRasRef = null;
            return wr;
        }
    }
    // If we are going to cache this Raster, make it non-tiny
    if (w <= 32 && h <= 32) {
        w = h = 32;
    }
    return srcRas.createCompatibleWritableRaster(w, h);
}
 
源代码7 项目: openjdk-8   文件: TexturePaintContext.java
synchronized static WritableRaster makeByteRaster(Raster srcRas,
                                                  int w, int h)
{
    if (byteRasRef != null) {
        WritableRaster wr = (WritableRaster) byteRasRef.get();
        if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) {
            byteRasRef = null;
            return wr;
        }
    }
    // If we are going to cache this Raster, make it non-tiny
    if (w <= 32 && h <= 32) {
        w = h = 32;
    }
    return srcRas.createCompatibleWritableRaster(w, h);
}
 
源代码8 项目: openjdk-8-source   文件: TexturePaintContext.java
synchronized static WritableRaster makeByteRaster(Raster srcRas,
                                                  int w, int h)
{
    if (byteRasRef != null) {
        WritableRaster wr = (WritableRaster) byteRasRef.get();
        if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) {
            byteRasRef = null;
            return wr;
        }
    }
    // If we are going to cache this Raster, make it non-tiny
    if (w <= 32 && h <= 32) {
        w = h = 32;
    }
    return srcRas.createCompatibleWritableRaster(w, h);
}
 
synchronized static WritableRaster makeByteRaster(Raster srcRas,
                                                  int w, int h)
{
    if (byteRasRef != null) {
        WritableRaster wr = (WritableRaster) byteRasRef.get();
        if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) {
            byteRasRef = null;
            return wr;
        }
    }
    // If we are going to cache this Raster, make it non-tiny
    if (w <= 32 && h <= 32) {
        w = h = 32;
    }
    return srcRas.createCompatibleWritableRaster(w, h);
}
 
源代码10 项目: jdk8u-dev-jdk   文件: TexturePaintContext.java
synchronized static WritableRaster makeByteRaster(Raster srcRas,
                                                  int w, int h)
{
    if (byteRasRef != null) {
        WritableRaster wr = (WritableRaster) byteRasRef.get();
        if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) {
            byteRasRef = null;
            return wr;
        }
    }
    // If we are going to cache this Raster, make it non-tiny
    if (w <= 32 && h <= 32) {
        w = h = 32;
    }
    return srcRas.createCompatibleWritableRaster(w, h);
}
 
源代码11 项目: openjdk-jdk9   文件: TexturePaintContext.java
static synchronized WritableRaster makeByteRaster(Raster srcRas,
                                                  int w, int h)
{
    if (byteRasRef != null) {
        WritableRaster wr = (WritableRaster) byteRasRef.get();
        if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) {
            byteRasRef = null;
            return wr;
        }
    }
    // If we are going to cache this Raster, make it non-tiny
    if (w <= 32 && h <= 32) {
        w = h = 32;
    }
    return srcRas.createCompatibleWritableRaster(w, h);
}
 
源代码12 项目: cognitivej   文件: PixelatedImageSectionFilter.java
@NotNull
@Override
public BufferedImage applyFilter(@NotNull BufferedImage bufferedImage) {
    Raster src = bufferedImage.getData();
    WritableRaster dest = src.createCompatibleWritableRaster();
    bufferedImage.copyData(dest);
    for (int y = pixelateSection.y; y < pixelateSection.y + pixelateSection.getHeight(); y += PIX_SIZE) {
        for (int x = pixelateSection.x; x < pixelateSection.x + pixelateSection.getWidth(); x += PIX_SIZE) {
            double[] pixel = new double[3];
            pixel = src.getPixel(x, y, pixel);
            for (int yd = y; (yd < y + PIX_SIZE) && (yd < dest.getHeight()); yd++) {
                for (int xd = x; (xd < x + PIX_SIZE) && (xd < dest.getWidth()); xd++) {
                    dest.setPixel(xd, yd, pixel);
                }
            }
        }
    }
    bufferedImage.setData(dest);
    return bufferedImage;
}
 
源代码13 项目: gcs   文件: DCTFilter.java
private WritableRaster fromYCCKtoCMYK(Raster raster)
{
    WritableRaster writableRaster = raster.createCompatibleWritableRaster();

    int[] value = new int[4];
    for (int y = 0, height = raster.getHeight(); y < height; y++)
    {
        for (int x = 0, width = raster.getWidth(); x < width; x++)
        {
            raster.getPixel(x, y, value);

            // 4-channels 0..255
            float Y = value[0];
            float Cb = value[1];
            float Cr = value[2];
            float K = value[3];

            // YCCK to RGB, see http://software.intel.com/en-us/node/442744
            int r = clamp(Y + 1.402f * Cr - 179.456f);
            int g = clamp(Y - 0.34414f * Cb - 0.71414f * Cr + 135.45984f);
            int b = clamp(Y + 1.772f * Cb - 226.816f);

            // naive RGB to CMYK
            int cyan = 255 - r;
            int magenta = 255 - g;
            int yellow = 255 - b;

            // update new raster
            value[0] = cyan;
            value[1] = magenta;
            value[2] = yellow;
            value[3] = (int)K;
            writableRaster.setPixel(x, y, value);
        }
    }
    return writableRaster;
}
 
源代码14 项目: orbit-image-analysis   文件: DLSegment.java
private static Raster flipRaster(Raster r) {
    int w = r.getWidth();
    int h = r.getHeight();
    WritableRaster rf = r.createCompatibleWritableRaster(r.getMinX(),r.getMinY(), w,h);
    int[] p = new int[w*3];
    for (int y=r.getMinY(); y<r.getMinY()+h; y++) {
        p = r.getPixels(r.getMinX(),y,w,1,p);
        rf.setPixels(r.getMinX(),r.getMinY()+h-(y-r.getMinY())-1,w,1,p);
    }
    return rf;
}
 
源代码15 项目: dragonwell8_jdk   文件: JPEGImageWriter.java
/**
 * Put the scanline y of the source ROI view Raster into the
 * 1-line Raster for writing.  This handles ROI and band
 * rearrangements, and expands indexed images.  Subsampling is
 * done in the native code.
 * This is called by the native code.
 */
private void grabPixels(int y) {

    Raster sourceLine = null;
    if (indexed) {
        sourceLine = srcRas.createChild(sourceXOffset,
                                        sourceYOffset+y,
                                        sourceWidth, 1,
                                        0, 0,
                                        new int [] {0});
        // If the image has BITMASK transparency, we need to make sure
        // it gets converted to 32-bit ARGB, because the JPEG encoder
        // relies upon the full 8-bit alpha channel.
        boolean forceARGB =
            (indexCM.getTransparency() != Transparency.OPAQUE);
        BufferedImage temp = indexCM.convertToIntDiscrete(sourceLine,
                                                          forceARGB);
        sourceLine = temp.getRaster();
    } else {
        sourceLine = srcRas.createChild(sourceXOffset,
                                        sourceYOffset+y,
                                        sourceWidth, 1,
                                        0, 0,
                                        srcBands);
    }
    if (convertTosRGB) {
        if (debug) {
            System.out.println("Converting to sRGB");
        }
        // The first time through, converted is null, so
        // a new raster is allocated.  It is then reused
        // on subsequent lines.
        converted = convertOp.filter(sourceLine, converted);
        sourceLine = converted;
    }
    if (isAlphaPremultiplied) {
        WritableRaster wr = sourceLine.createCompatibleWritableRaster();
        int[] data = null;
        data = sourceLine.getPixels(sourceLine.getMinX(), sourceLine.getMinY(),
                                    sourceLine.getWidth(), sourceLine.getHeight(),
                                    data);
        wr.setPixels(sourceLine.getMinX(), sourceLine.getMinY(),
                     sourceLine.getWidth(), sourceLine.getHeight(),
                     data);
        srcCM.coerceData(wr, false);
        sourceLine = wr.createChild(wr.getMinX(), wr.getMinY(),
                                    wr.getWidth(), wr.getHeight(),
                                    0, 0,
                                    srcBands);
    }
    raster.setRect(sourceLine);
    if ((y > 7) && (y%8 == 0)) {  // Every 8 scanlines
        cbLock.lock();
        try {
            processImageProgress((float) y / (float) sourceHeight * 100.0F);
        } finally {
            cbLock.unlock();
        }
    }
}
 
源代码16 项目: hottub   文件: JPEGImageWriter.java
/**
 * Put the scanline y of the source ROI view Raster into the
 * 1-line Raster for writing.  This handles ROI and band
 * rearrangements, and expands indexed images.  Subsampling is
 * done in the native code.
 * This is called by the native code.
 */
private void grabPixels(int y) {

    Raster sourceLine = null;
    if (indexed) {
        sourceLine = srcRas.createChild(sourceXOffset,
                                        sourceYOffset+y,
                                        sourceWidth, 1,
                                        0, 0,
                                        new int [] {0});
        // If the image has BITMASK transparency, we need to make sure
        // it gets converted to 32-bit ARGB, because the JPEG encoder
        // relies upon the full 8-bit alpha channel.
        boolean forceARGB =
            (indexCM.getTransparency() != Transparency.OPAQUE);
        BufferedImage temp = indexCM.convertToIntDiscrete(sourceLine,
                                                          forceARGB);
        sourceLine = temp.getRaster();
    } else {
        sourceLine = srcRas.createChild(sourceXOffset,
                                        sourceYOffset+y,
                                        sourceWidth, 1,
                                        0, 0,
                                        srcBands);
    }
    if (convertTosRGB) {
        if (debug) {
            System.out.println("Converting to sRGB");
        }
        // The first time through, converted is null, so
        // a new raster is allocated.  It is then reused
        // on subsequent lines.
        converted = convertOp.filter(sourceLine, converted);
        sourceLine = converted;
    }
    if (isAlphaPremultiplied) {
        WritableRaster wr = sourceLine.createCompatibleWritableRaster();
        int[] data = null;
        data = sourceLine.getPixels(sourceLine.getMinX(), sourceLine.getMinY(),
                                    sourceLine.getWidth(), sourceLine.getHeight(),
                                    data);
        wr.setPixels(sourceLine.getMinX(), sourceLine.getMinY(),
                     sourceLine.getWidth(), sourceLine.getHeight(),
                     data);
        srcCM.coerceData(wr, false);
        sourceLine = wr.createChild(wr.getMinX(), wr.getMinY(),
                                    wr.getWidth(), wr.getHeight(),
                                    0, 0,
                                    srcBands);
    }
    raster.setRect(sourceLine);
    if ((y > 7) && (y%8 == 0)) {  // Every 8 scanlines
        cbLock.lock();
        try {
            processImageProgress((float) y / (float) sourceHeight * 100.0F);
        } finally {
            cbLock.unlock();
        }
    }
}
 
源代码17 项目: jdk8u60   文件: JPEGImageWriter.java
/**
 * Put the scanline y of the source ROI view Raster into the
 * 1-line Raster for writing.  This handles ROI and band
 * rearrangements, and expands indexed images.  Subsampling is
 * done in the native code.
 * This is called by the native code.
 */
private void grabPixels(int y) {

    Raster sourceLine = null;
    if (indexed) {
        sourceLine = srcRas.createChild(sourceXOffset,
                                        sourceYOffset+y,
                                        sourceWidth, 1,
                                        0, 0,
                                        new int [] {0});
        // If the image has BITMASK transparency, we need to make sure
        // it gets converted to 32-bit ARGB, because the JPEG encoder
        // relies upon the full 8-bit alpha channel.
        boolean forceARGB =
            (indexCM.getTransparency() != Transparency.OPAQUE);
        BufferedImage temp = indexCM.convertToIntDiscrete(sourceLine,
                                                          forceARGB);
        sourceLine = temp.getRaster();
    } else {
        sourceLine = srcRas.createChild(sourceXOffset,
                                        sourceYOffset+y,
                                        sourceWidth, 1,
                                        0, 0,
                                        srcBands);
    }
    if (convertTosRGB) {
        if (debug) {
            System.out.println("Converting to sRGB");
        }
        // The first time through, converted is null, so
        // a new raster is allocated.  It is then reused
        // on subsequent lines.
        converted = convertOp.filter(sourceLine, converted);
        sourceLine = converted;
    }
    if (isAlphaPremultiplied) {
        WritableRaster wr = sourceLine.createCompatibleWritableRaster();
        int[] data = null;
        data = sourceLine.getPixels(sourceLine.getMinX(), sourceLine.getMinY(),
                                    sourceLine.getWidth(), sourceLine.getHeight(),
                                    data);
        wr.setPixels(sourceLine.getMinX(), sourceLine.getMinY(),
                     sourceLine.getWidth(), sourceLine.getHeight(),
                     data);
        srcCM.coerceData(wr, false);
        sourceLine = wr.createChild(wr.getMinX(), wr.getMinY(),
                                    wr.getWidth(), wr.getHeight(),
                                    0, 0,
                                    srcBands);
    }
    raster.setRect(sourceLine);
    if ((y > 7) && (y%8 == 0)) {  // Every 8 scanlines
        cbLock.lock();
        try {
            processImageProgress((float) y / (float) sourceHeight * 100.0F);
        } finally {
            cbLock.unlock();
        }
    }
}
 
源代码18 项目: openjdk-jdk8u-backup   文件: JPEGImageWriter.java
/**
 * Put the scanline y of the source ROI view Raster into the
 * 1-line Raster for writing.  This handles ROI and band
 * rearrangements, and expands indexed images.  Subsampling is
 * done in the native code.
 * This is called by the native code.
 */
private void grabPixels(int y) {

    Raster sourceLine = null;
    if (indexed) {
        sourceLine = srcRas.createChild(sourceXOffset,
                                        sourceYOffset+y,
                                        sourceWidth, 1,
                                        0, 0,
                                        new int [] {0});
        // If the image has BITMASK transparency, we need to make sure
        // it gets converted to 32-bit ARGB, because the JPEG encoder
        // relies upon the full 8-bit alpha channel.
        boolean forceARGB =
            (indexCM.getTransparency() != Transparency.OPAQUE);
        BufferedImage temp = indexCM.convertToIntDiscrete(sourceLine,
                                                          forceARGB);
        sourceLine = temp.getRaster();
    } else {
        sourceLine = srcRas.createChild(sourceXOffset,
                                        sourceYOffset+y,
                                        sourceWidth, 1,
                                        0, 0,
                                        srcBands);
    }
    if (convertTosRGB) {
        if (debug) {
            System.out.println("Converting to sRGB");
        }
        // The first time through, converted is null, so
        // a new raster is allocated.  It is then reused
        // on subsequent lines.
        converted = convertOp.filter(sourceLine, converted);
        sourceLine = converted;
    }
    if (isAlphaPremultiplied) {
        WritableRaster wr = sourceLine.createCompatibleWritableRaster();
        int[] data = null;
        data = sourceLine.getPixels(sourceLine.getMinX(), sourceLine.getMinY(),
                                    sourceLine.getWidth(), sourceLine.getHeight(),
                                    data);
        wr.setPixels(sourceLine.getMinX(), sourceLine.getMinY(),
                     sourceLine.getWidth(), sourceLine.getHeight(),
                     data);
        srcCM.coerceData(wr, false);
        sourceLine = wr.createChild(wr.getMinX(), wr.getMinY(),
                                    wr.getWidth(), wr.getHeight(),
                                    0, 0,
                                    srcBands);
    }
    raster.setRect(sourceLine);
    if ((y > 7) && (y%8 == 0)) {  // Every 8 scanlines
        cbLock.lock();
        try {
            processImageProgress((float) y / (float) sourceHeight * 100.0F);
        } finally {
            cbLock.unlock();
        }
    }
}
 
源代码19 项目: Bytecoder   文件: JPEGImageWriter.java
/**
 * Put the scanline y of the source ROI view Raster into the
 * 1-line Raster for writing.  This handles ROI and band
 * rearrangements, and expands indexed images.  Subsampling is
 * done in the native code.
 * This is called by the native code.
 */
private void grabPixels(int y) {

    Raster sourceLine = null;
    if (indexed) {
        sourceLine = srcRas.createChild(sourceXOffset,
                                        sourceYOffset+y,
                                        sourceWidth, 1,
                                        0, 0,
                                        new int [] {0});
        // If the image has BITMASK transparency, we need to make sure
        // it gets converted to 32-bit ARGB, because the JPEG encoder
        // relies upon the full 8-bit alpha channel.
        boolean forceARGB =
            (indexCM.getTransparency() != Transparency.OPAQUE);
        BufferedImage temp = indexCM.convertToIntDiscrete(sourceLine,
                                                          forceARGB);
        sourceLine = temp.getRaster();
    } else {
        sourceLine = srcRas.createChild(sourceXOffset,
                                        sourceYOffset+y,
                                        sourceWidth, 1,
                                        0, 0,
                                        srcBands);
    }
    if (convertTosRGB) {
        if (debug) {
            System.out.println("Converting to sRGB");
        }
        // The first time through, converted is null, so
        // a new raster is allocated.  It is then reused
        // on subsequent lines.
        converted = convertOp.filter(sourceLine, converted);
        sourceLine = converted;
    }
    if (isAlphaPremultiplied) {
        WritableRaster wr = sourceLine.createCompatibleWritableRaster();
        int[] data = null;
        data = sourceLine.getPixels(sourceLine.getMinX(), sourceLine.getMinY(),
                                    sourceLine.getWidth(), sourceLine.getHeight(),
                                    data);
        wr.setPixels(sourceLine.getMinX(), sourceLine.getMinY(),
                     sourceLine.getWidth(), sourceLine.getHeight(),
                     data);
        srcCM.coerceData(wr, false);
        sourceLine = wr.createChild(wr.getMinX(), wr.getMinY(),
                                    wr.getWidth(), wr.getHeight(),
                                    0, 0,
                                    srcBands);
    }
    raster.setRect(sourceLine);
    if ((y > 7) && (y%8 == 0)) {  // Every 8 scanlines
        cbLock.lock();
        try {
            processImageProgress((float) y / (float) sourceHeight * 100.0F);
        } finally {
            cbLock.unlock();
        }
    }
}
 
源代码20 项目: jdk8u-jdk   文件: JPEGImageWriter.java
/**
 * Put the scanline y of the source ROI view Raster into the
 * 1-line Raster for writing.  This handles ROI and band
 * rearrangements, and expands indexed images.  Subsampling is
 * done in the native code.
 * This is called by the native code.
 */
private void grabPixels(int y) {

    Raster sourceLine = null;
    if (indexed) {
        sourceLine = srcRas.createChild(sourceXOffset,
                                        sourceYOffset+y,
                                        sourceWidth, 1,
                                        0, 0,
                                        new int [] {0});
        // If the image has BITMASK transparency, we need to make sure
        // it gets converted to 32-bit ARGB, because the JPEG encoder
        // relies upon the full 8-bit alpha channel.
        boolean forceARGB =
            (indexCM.getTransparency() != Transparency.OPAQUE);
        BufferedImage temp = indexCM.convertToIntDiscrete(sourceLine,
                                                          forceARGB);
        sourceLine = temp.getRaster();
    } else {
        sourceLine = srcRas.createChild(sourceXOffset,
                                        sourceYOffset+y,
                                        sourceWidth, 1,
                                        0, 0,
                                        srcBands);
    }
    if (convertTosRGB) {
        if (debug) {
            System.out.println("Converting to sRGB");
        }
        // The first time through, converted is null, so
        // a new raster is allocated.  It is then reused
        // on subsequent lines.
        converted = convertOp.filter(sourceLine, converted);
        sourceLine = converted;
    }
    if (isAlphaPremultiplied) {
        WritableRaster wr = sourceLine.createCompatibleWritableRaster();
        int[] data = null;
        data = sourceLine.getPixels(sourceLine.getMinX(), sourceLine.getMinY(),
                                    sourceLine.getWidth(), sourceLine.getHeight(),
                                    data);
        wr.setPixels(sourceLine.getMinX(), sourceLine.getMinY(),
                     sourceLine.getWidth(), sourceLine.getHeight(),
                     data);
        srcCM.coerceData(wr, false);
        sourceLine = wr.createChild(wr.getMinX(), wr.getMinY(),
                                    wr.getWidth(), wr.getHeight(),
                                    0, 0,
                                    srcBands);
    }
    raster.setRect(sourceLine);
    if ((y > 7) && (y%8 == 0)) {  // Every 8 scanlines
        cbLock.lock();
        try {
            processImageProgress((float) y / (float) sourceHeight * 100.0F);
        } finally {
            cbLock.unlock();
        }
    }
}