Java Code Examples for java.awt.image.WritableRaster#setDataElements()
The following examples show how to use
java.awt.image.WritableRaster#setDataElements() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphicsUtilities.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * <p>Writes a rectangular area of pixels in the destination * <code>BufferedImage</code>. Calling this method on * an image of type different from <code>BufferedImage.TYPE_INT_ARGB</code> * and <code>BufferedImage.TYPE_INT_RGB</code> will unmanage the image.</p> * * @param img the destination image * @param x the x location at which to start storing pixels * @param y the y location at which to start storing pixels * @param w the width of the rectangle of pixels to store * @param h the height of the rectangle of pixels to store * @param pixels an array of pixels, stored as integers * @throws IllegalArgumentException is <code>pixels</code> is non-null and * of length < w*h */ public static void setPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) { if (pixels == null || w == 0 || h == 0) { return; } else if (pixels.length < w * h) { throw new IllegalArgumentException("pixels array must have a length" + " >= w*h"); } int imageType = img.getType(); if (imageType == BufferedImage.TYPE_INT_ARGB || imageType == BufferedImage.TYPE_INT_RGB) { WritableRaster raster = img.getRaster(); raster.setDataElements(x, y, w, h, pixels); } else { // Unmanages the image img.setRGB(x, y, w, h, pixels, 0, w); } }
Example 2
Source File: GraphicsUtilities.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * <p>Writes a rectangular area of pixels in the destination * <code>BufferedImage</code>. Calling this method on * an image of type different from <code>BufferedImage.TYPE_INT_ARGB</code> * and <code>BufferedImage.TYPE_INT_RGB</code> will unmanage the image.</p> * * @param img the destination image * @param x the x location at which to start storing pixels * @param y the y location at which to start storing pixels * @param w the width of the rectangle of pixels to store * @param h the height of the rectangle of pixels to store * @param pixels an array of pixels, stored as integers * @throws IllegalArgumentException is <code>pixels</code> is non-null and * of length < w*h */ public static void setPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) { if (pixels == null || w == 0 || h == 0) { return; } else if (pixels.length < w * h) { throw new IllegalArgumentException("pixels array must have a length" + " >= w*h"); } int imageType = img.getType(); if (imageType == BufferedImage.TYPE_INT_ARGB || imageType == BufferedImage.TYPE_INT_RGB) { WritableRaster raster = img.getRaster(); raster.setDataElements(x, y, w, h, pixels); } else { // Unmanages the image img.setRGB(x, y, w, h, pixels, 0, w); } }
Example 3
Source File: GraphicsUtilities.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * <p>Writes a rectangular area of pixels in the destination * <code>BufferedImage</code>. Calling this method on * an image of type different from <code>BufferedImage.TYPE_INT_ARGB</code> * and <code>BufferedImage.TYPE_INT_RGB</code> will unmanage the image.</p> * * @param img the destination image * @param x the x location at which to start storing pixels * @param y the y location at which to start storing pixels * @param w the width of the rectangle of pixels to store * @param h the height of the rectangle of pixels to store * @param pixels an array of pixels, stored as integers * @throws IllegalArgumentException is <code>pixels</code> is non-null and * of length < w*h */ public static void setPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) { if (pixels == null || w == 0 || h == 0) { return; } else if (pixels.length < w * h) { throw new IllegalArgumentException("pixels array must have a length" + " >= w*h"); } int imageType = img.getType(); if (imageType == BufferedImage.TYPE_INT_ARGB || imageType == BufferedImage.TYPE_INT_RGB) { WritableRaster raster = img.getRaster(); raster.setDataElements(x, y, w, h, pixels); } else { // Unmanages the image img.setRGB(x, y, w, h, pixels, 0, w); } }
Example 4
Source File: DrawReconstruction.java From Canova with Apache License 2.0 | 6 votes |
public void draw() { WritableRaster r = img.getRaster(); int[] equiv = new int[data.length()]; INDArray dataLinear = data.linearView(); for(int i = 0; i < equiv.length; i++) equiv[i] = Math.round(dataLinear.getInt(i)); r.setDataElements(0, 0, width, height, equiv); frame = new JFrame(title); frame.setVisible(true); start(); frame.add(new JLabel(new ImageIcon(getImage()))); frame.pack(); // Better to DISPOSE than EXIT frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); }
Example 5
Source File: EffectUtils.java From Java8CN with Apache License 2.0 | 6 votes |
/** * <p>Writes a rectangular area of pixels in the destination * <code>BufferedImage</code>. Calling this method on * an image of type different from <code>BufferedImage.TYPE_INT_ARGB</code> * and <code>BufferedImage.TYPE_INT_RGB</code> will unmanage the image.</p> * * @param img the destination image * @param x the x location at which to start storing pixels * @param y the y location at which to start storing pixels * @param w the width of the rectangle of pixels to store * @param h the height of the rectangle of pixels to store * @param pixels an array of pixels, stored as integers * @throws IllegalArgumentException is <code>pixels</code> is non-null and * of length < w*h */ public static void setPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) { if (pixels == null || w == 0 || h == 0) { return; } else if (pixels.length < w * h) { throw new IllegalArgumentException("pixels array must have a length" + " >= w*h"); } int imageType = img.getType(); if (imageType == BufferedImage.TYPE_INT_ARGB || imageType == BufferedImage.TYPE_INT_RGB) { WritableRaster raster = img.getRaster(); raster.setDataElements(x, y, w, h, pixels); } else { // Unmanages the image img.setRGB(x, y, w, h, pixels, 0, w); } }
Example 6
Source File: EffectUtils.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * <p>Writes a rectangular area of pixels in the destination * <code>BufferedImage</code>. Calling this method on * an image of type different from <code>BufferedImage.TYPE_INT_ARGB</code> * and <code>BufferedImage.TYPE_INT_RGB</code> will unmanage the image.</p> * * @param img the destination image * @param x the x location at which to start storing pixels * @param y the y location at which to start storing pixels * @param w the width of the rectangle of pixels to store * @param h the height of the rectangle of pixels to store * @param pixels an array of pixels, stored as integers * @throws IllegalArgumentException is <code>pixels</code> is non-null and * of length < w*h */ public static void setPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) { if (pixels == null || w == 0 || h == 0) { return; } else if (pixels.length < w * h) { throw new IllegalArgumentException("pixels array must have a length" + " >= w*h"); } int imageType = img.getType(); if (imageType == BufferedImage.TYPE_INT_ARGB || imageType == BufferedImage.TYPE_INT_RGB) { WritableRaster raster = img.getRaster(); raster.setDataElements(x, y, w, h, pixels); } else { // Unmanages the image img.setRGB(x, y, w, h, pixels, 0, w); } }
Example 7
Source File: EffectUtils.java From seaglass with Apache License 2.0 | 6 votes |
/** * <p>Writes a rectangular area of pixels in the destination <code> * BufferedImage</code>. Calling this method on an image of type different * from <code>BufferedImage.TYPE_INT_ARGB</code> and <code> * BufferedImage.TYPE_INT_RGB</code> will unmanage the image.</p> * * @param img the destination image * @param x the x location at which to start storing pixels * @param y the y location at which to start storing pixels * @param w the width of the rectangle of pixels to store * @param h the height of the rectangle of pixels to store * @param pixels an array of pixels, stored as integers */ static void setPixels(BufferedImage img, int x, int y, int w, int h, byte[] pixels) { if (pixels == null || w == 0 || h == 0) { return; } else if (pixels.length < w * h) { throw new IllegalArgumentException("pixels array must have a length >= w*h"); } int imageType = img.getType(); if (imageType == BufferedImage.TYPE_BYTE_GRAY) { WritableRaster raster = img.getRaster(); raster.setDataElements(x, y, w, h, pixels); } else { throw new IllegalArgumentException("Only type BYTE_GRAY is supported"); } }
Example 8
Source File: EffectUtils.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * <p>Writes a rectangular area of pixels in the destination <code>BufferedImage</code>. Calling this method on an * image of type different from <code>BufferedImage.TYPE_INT_ARGB</code> and <code>BufferedImage.TYPE_INT_RGB</code> * will unmanage the image.</p> * * @param img the destination image * @param x the x location at which to start storing pixels * @param y the y location at which to start storing pixels * @param w the width of the rectangle of pixels to store * @param h the height of the rectangle of pixels to store * @param pixels an array of pixels, stored as integers * @throws IllegalArgumentException is <code>pixels</code> is non-null and of length < w*h */ static void setPixels(BufferedImage img, int x, int y, int w, int h, byte[] pixels) { if (pixels == null || w == 0 || h == 0) { return; } else if (pixels.length < w * h) { throw new IllegalArgumentException("pixels array must have a length >= w*h"); } int imageType = img.getType(); if (imageType == BufferedImage.TYPE_BYTE_GRAY) { WritableRaster raster = img.getRaster(); raster.setDataElements(x, y, w, h, pixels); } else { throw new IllegalArgumentException("Only type BYTE_GRAY is supported"); } }
Example 9
Source File: GraphicsUtilities.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * <p>Writes a rectangular area of pixels in the destination * <code>BufferedImage</code>. Calling this method on * an image of type different from <code>BufferedImage.TYPE_INT_ARGB</code> * and <code>BufferedImage.TYPE_INT_RGB</code> will unmanage the image.</p> * * @param img the destination image * @param x the x location at which to start storing pixels * @param y the y location at which to start storing pixels * @param w the width of the rectangle of pixels to store * @param h the height of the rectangle of pixels to store * @param pixels an array of pixels, stored as integers * @throws IllegalArgumentException is <code>pixels</code> is non-null and * of length < w*h */ public static void setPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) { if (pixels == null || w == 0 || h == 0) { return; } else if (pixels.length < w * h) { throw new IllegalArgumentException("pixels array must have a length" + " >= w*h"); } int imageType = img.getType(); if (imageType == BufferedImage.TYPE_INT_ARGB || imageType == BufferedImage.TYPE_INT_RGB) { WritableRaster raster = img.getRaster(); raster.setDataElements(x, y, w, h, pixels); } else { // Unmanages the image img.setRGB(x, y, w, h, pixels, 0, w); } }
Example 10
Source File: EffectUtils.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * <p>Writes a rectangular area of pixels in the destination <code>BufferedImage</code>. Calling this method on an * image of type different from <code>BufferedImage.TYPE_INT_ARGB</code> and <code>BufferedImage.TYPE_INT_RGB</code> * will unmanage the image.</p> * * @param img the destination image * @param x the x location at which to start storing pixels * @param y the y location at which to start storing pixels * @param w the width of the rectangle of pixels to store * @param h the height of the rectangle of pixels to store * @param pixels an array of pixels, stored as integers * @throws IllegalArgumentException is <code>pixels</code> is non-null and of length < w*h */ static void setPixels(BufferedImage img, int x, int y, int w, int h, byte[] pixels) { if (pixels == null || w == 0 || h == 0) { return; } else if (pixels.length < w * h) { throw new IllegalArgumentException("pixels array must have a length >= w*h"); } int imageType = img.getType(); if (imageType == BufferedImage.TYPE_BYTE_GRAY) { WritableRaster raster = img.getRaster(); raster.setDataElements(x, y, w, h, pixels); } else { throw new IllegalArgumentException("Only type BYTE_GRAY is supported"); } }
Example 11
Source File: GraphicsUtilities.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * <p>Writes a rectangular area of pixels in the destination * <code>BufferedImage</code>. Calling this method on * an image of type different from <code>BufferedImage.TYPE_INT_ARGB</code> * and <code>BufferedImage.TYPE_INT_RGB</code> will unmanage the image.</p> * * @param img the destination image * @param x the x location at which to start storing pixels * @param y the y location at which to start storing pixels * @param w the width of the rectangle of pixels to store * @param h the height of the rectangle of pixels to store * @param pixels an array of pixels, stored as integers * @throws IllegalArgumentException is <code>pixels</code> is non-null and * of length < w*h */ public static void setPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) { if (pixels == null || w == 0 || h == 0) { return; } else if (pixels.length < w * h) { throw new IllegalArgumentException("pixels array must have a length" + " >= w*h"); } int imageType = img.getType(); if (imageType == BufferedImage.TYPE_INT_ARGB || imageType == BufferedImage.TYPE_INT_RGB) { WritableRaster raster = img.getRaster(); raster.setDataElements(x, y, w, h, pixels); } else { // Unmanages the image img.setRGB(x, y, w, h, pixels, 0, w); } }
Example 12
Source File: PixelTests.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void runTest(Object context, int numReps) { WritableRaster ras = ((Context) context).ras; Object elemdata = ((Context) context).elemdata; do { ras.setDataElements(numReps&7, 0, elemdata); } while (--numReps > 0); }
Example 13
Source File: CustomComponent.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int srcx, int srcy, int dstx, int dsty, int w, int h) { Raster srcRast = src.getRaster(srcx, srcy, w, h); IntegerComponentRaster icr = (IntegerComponentRaster) srcRast; int[] srcPix = icr.getDataStorage(); WritableRaster dstRast = (WritableRaster) dst.getRaster(dstx, dsty, w, h); ColorModel dstCM = dst.getColorModel(); Region roi = CustomComponent.getRegionOfInterest(src, dst, clip, srcx, srcy, dstx, dsty, w, h); SpanIterator si = roi.getSpanIterator(); Object dstPix = null; int srcScan = icr.getScanlineStride(); // assert(icr.getPixelStride() == 1); srcx -= dstx; srcy -= dsty; int span[] = new int[4]; while (si.nextSpan(span)) { int rowoff = (icr.getDataOffset(0) + (srcy + span[1]) * srcScan + (srcx + span[0])); for (int y = span[1]; y < span[3]; y++) { int off = rowoff; for (int x = span[0]; x < span[2]; x++) { dstPix = dstCM.getDataElements(srcPix[off++], dstPix); dstRast.setDataElements(x, y, dstPix); } rowoff += srcScan; } } // REMIND: We need to do something to make sure that dstRast // is put back to the destination (as in the native Release // function) // src.releaseRaster(srcRast); // NOP? // dst.releaseRaster(dstRast); }
Example 14
Source File: BlendComposite.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { int width = Math.min(src.getWidth(), dstIn.getWidth()); int height = Math.min(src.getHeight(), dstIn.getHeight()); float alpha = composite.getAlpha(); int[] result = new int[4]; int[] srcPixel = new int[4]; int[] dstPixel = new int[4]; int[] srcPixels = new int[width]; int[] dstPixels = new int[width]; for (int y = 0; y < height; y++) { src.getDataElements(0, y, width, 1, srcPixels); dstIn.getDataElements(0, y, width, 1, dstPixels); for (int x = 0; x < width; x++) { // pixels are stored as INT_ARGB // our arrays are [R, G, B, A] int pixel = srcPixels[x]; srcPixel[0] = (pixel >> 16) & 0xFF; srcPixel[1] = (pixel >> 8) & 0xFF; srcPixel[2] = (pixel ) & 0xFF; srcPixel[3] = (pixel >> 24) & 0xFF; pixel = dstPixels[x]; dstPixel[0] = (pixel >> 16) & 0xFF; dstPixel[1] = (pixel >> 8) & 0xFF; dstPixel[2] = (pixel ) & 0xFF; dstPixel[3] = (pixel >> 24) & 0xFF; blender.blend(srcPixel, dstPixel, result); // mixes the result with the opacity dstPixels[x] = ((int) (dstPixel[3] + (result[3] - dstPixel[3]) * alpha) & 0xFF) << 24 | ((int) (dstPixel[0] + (result[0] - dstPixel[0]) * alpha) & 0xFF) << 16 | ((int) (dstPixel[1] + (result[1] - dstPixel[1]) * alpha) & 0xFF) << 8 | (int) (dstPixel[2] + (result[2] - dstPixel[2]) * alpha) & 0xFF; } dstOut.setDataElements(0, y, width, 1, dstPixels); } }
Example 15
Source File: BlendComposite.java From scrimage with Apache License 2.0 | 4 votes |
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { if (src.getSampleModel().getDataType() != DataBuffer.TYPE_INT || dstIn.getSampleModel().getDataType() != DataBuffer.TYPE_INT || dstOut.getSampleModel().getDataType() != DataBuffer.TYPE_INT) { throw new IllegalStateException( "Source and destination must store pixels as INT."); } int width = Math.min(src.getWidth(), dstIn.getWidth()); int height = Math.min(src.getHeight(), dstIn.getHeight()); float alpha = composite.getAlpha(); int[] srcPixel = new int[4]; int[] dstPixel = new int[4]; int[] srcPixels = new int[width]; int[] dstPixels = new int[width]; for (int y = 0; y < height; y++) { src.getDataElements(0, y, width, 1, srcPixels); dstIn.getDataElements(0, y, width, 1, dstPixels); for (int x = 0; x < width; x++) { // pixels are stored as INT_ARGB // our arrays are [R, G, B, A] int pixel = srcPixels[x]; srcPixel[0] = (pixel >> 16) & 0xFF; srcPixel[1] = (pixel >> 8) & 0xFF; srcPixel[2] = (pixel) & 0xFF; srcPixel[3] = (pixel >> 24) & 0xFF; pixel = dstPixels[x]; dstPixel[0] = (pixel >> 16) & 0xFF; dstPixel[1] = (pixel >> 8) & 0xFF; dstPixel[2] = (pixel) & 0xFF; dstPixel[3] = (pixel >> 24) & 0xFF; int[] result = blender.blend(srcPixel, dstPixel); // mixes the result with the opacity dstPixels[x] = ((int) (dstPixel[3] + (result[3] - dstPixel[3]) * alpha) & 0xFF) << 24 | ((int) (dstPixel[0] + (result[0] - dstPixel[0]) * alpha) & 0xFF) << 16 | ((int) (dstPixel[1] + (result[1] - dstPixel[1]) * alpha) & 0xFF) << 8 | (int) (dstPixel[2] + (result[2] - dstPixel[2]) * alpha) & 0xFF; } dstOut.setDataElements(0, y, width, 1, dstPixels); } }
Example 16
Source File: CustomComponent.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int srcx, int srcy, int dstx, int dsty, int w, int h) { Raster srcRast = src.getRaster(srcx, srcy, w, h); IntegerComponentRaster icr = (IntegerComponentRaster) srcRast; int[] srcPix = icr.getDataStorage(); WritableRaster dstRast = (WritableRaster) dst.getRaster(dstx, dsty, w, h); ColorModel dstCM = dst.getColorModel(); Region roi = CustomComponent.getRegionOfInterest(src, dst, clip, srcx, srcy, dstx, dsty, w, h); SpanIterator si = roi.getSpanIterator(); Object dstPix = null; int srcScan = icr.getScanlineStride(); // assert(icr.getPixelStride() == 1); srcx -= dstx; srcy -= dsty; int span[] = new int[4]; while (si.nextSpan(span)) { int rowoff = (icr.getDataOffset(0) + (srcy + span[1]) * srcScan + (srcx + span[0])); for (int y = span[1]; y < span[3]; y++) { int off = rowoff; for (int x = span[0]; x < span[2]; x++) { dstPix = dstCM.getDataElements(srcPix[off++], dstPix); dstRast.setDataElements(x, y, dstPix); } rowoff += srcScan; } } // REMIND: We need to do something to make sure that dstRast // is put back to the destination (as in the native Release // function) // src.releaseRaster(srcRast); // NOP? // dst.releaseRaster(dstRast); }
Example 17
Source File: CustomComponent.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int srcx, int srcy, int dstx, int dsty, int w, int h) { Raster srcRast = src.getRaster(srcx, srcy, w, h); IntegerComponentRaster icr = (IntegerComponentRaster) srcRast; int[] srcPix = icr.getDataStorage(); WritableRaster dstRast = (WritableRaster) dst.getRaster(dstx, dsty, w, h); ColorModel dstCM = dst.getColorModel(); Region roi = CustomComponent.getRegionOfInterest(src, dst, clip, srcx, srcy, dstx, dsty, w, h); SpanIterator si = roi.getSpanIterator(); Object dstPix = null; int srcScan = icr.getScanlineStride(); // assert(icr.getPixelStride() == 1); srcx -= dstx; srcy -= dsty; int span[] = new int[4]; while (si.nextSpan(span)) { int rowoff = (icr.getDataOffset(0) + (srcy + span[1]) * srcScan + (srcx + span[0])); for (int y = span[1]; y < span[3]; y++) { int off = rowoff; for (int x = span[0]; x < span[2]; x++) { dstPix = dstCM.getDataElements(srcPix[off++], dstPix); dstRast.setDataElements(x, y, dstPix); } rowoff += srcScan; } } // REMIND: We need to do something to make sure that dstRast // is put back to the destination (as in the native Release // function) // src.releaseRaster(srcRast); // NOP? // dst.releaseRaster(dstRast); }
Example 18
Source File: CustomComponent.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int srcx, int srcy, int dstx, int dsty, int w, int h) { Raster srcRast = src.getRaster(srcx, srcy, w, h); IntegerComponentRaster icr = (IntegerComponentRaster) srcRast; int[] srcPix = icr.getDataStorage(); WritableRaster dstRast = (WritableRaster) dst.getRaster(dstx, dsty, w, h); ColorModel dstCM = dst.getColorModel(); Region roi = CustomComponent.getRegionOfInterest(src, dst, clip, srcx, srcy, dstx, dsty, w, h); SpanIterator si = roi.getSpanIterator(); Object dstPix = null; int srcScan = icr.getScanlineStride(); // assert(icr.getPixelStride() == 1); srcx -= dstx; srcy -= dsty; int span[] = new int[4]; while (si.nextSpan(span)) { int rowoff = (icr.getDataOffset(0) + (srcy + span[1]) * srcScan + (srcx + span[0])); for (int y = span[1]; y < span[3]; y++) { int off = rowoff; for (int x = span[0]; x < span[2]; x++) { dstPix = dstCM.getDataElements(srcPix[off++], dstPix); dstRast.setDataElements(x, y, dstPix); } rowoff += srcScan; } } // REMIND: We need to do something to make sure that dstRast // is put back to the destination (as in the native Release // function) // src.releaseRaster(srcRast); // NOP? // dst.releaseRaster(dstRast); }
Example 19
Source File: TexturePaintContext.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public void setRaster(int x, int y, int xerr, int yerr, int w, int h, int bWidth, int bHeight, int colincx, int colincxerr, int colincy, int colincyerr, int rowincx, int rowincxerr, int rowincy, int rowincyerr) { Object data = null; int rowx = x; int rowy = y; int rowxerr = xerr; int rowyerr = yerr; WritableRaster srcRas = this.srcRas; WritableRaster outRas = this.outRas; int rgbs[] = filter ? new int[4] : null; for (int j = 0; j < h; j++) { x = rowx; y = rowy; xerr = rowxerr; yerr = rowyerr; for (int i = 0; i < w; i++) { data = srcRas.getDataElements(x, y, data); if (filter) { int nextx, nexty; if ((nextx = x + 1) >= bWidth) { nextx = 0; } if ((nexty = y + 1) >= bHeight) { nexty = 0; } rgbs[0] = colorModel.getRGB(data); data = srcRas.getDataElements(nextx, y, data); rgbs[1] = colorModel.getRGB(data); data = srcRas.getDataElements(x, nexty, data); rgbs[2] = colorModel.getRGB(data); data = srcRas.getDataElements(nextx, nexty, data); rgbs[3] = colorModel.getRGB(data); int rgb = TexturePaintContext.blend(rgbs, xerr, yerr); data = colorModel.getDataElements(rgb, data); } outRas.setDataElements(i, j, data); if ((xerr += colincxerr) < 0) { xerr &= Integer.MAX_VALUE; x++; } if ((x += colincx) >= bWidth) { x -= bWidth; } if ((yerr += colincyerr) < 0) { yerr &= Integer.MAX_VALUE; y++; } if ((y += colincy) >= bHeight) { y -= bHeight; } } if ((rowxerr += rowincxerr) < 0) { rowxerr &= Integer.MAX_VALUE; rowx++; } if ((rowx += rowincx) >= bWidth) { rowx -= bWidth; } if ((rowyerr += rowincyerr) < 0) { rowyerr &= Integer.MAX_VALUE; rowy++; } if ((rowy += rowincy) >= bHeight) { rowy -= bHeight; } } }
Example 20
Source File: CoverageDataPng.java From geopackage-java with MIT License | 2 votes |
/** * Set the "unsigned short" pixel value into the image raster * * @param raster * image raster * @param x * x coordinate * @param y * y coordinate * @param pixelValue * "unsigned short" pixel value */ public void setPixelValue(WritableRaster raster, int x, int y, short pixelValue) { short data[] = new short[] { pixelValue }; raster.setDataElements(x, y, data); }