Java Code Examples for java.awt.image.RenderedImage#getTile()
The following examples show how to use
java.awt.image.RenderedImage#getTile() .
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: GIFImageWriter.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { if (abortRequested()) { processWriteAborted(); return; } processImageProgress((numRowsWritten*100.0F)/dh); } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 2
Source File: MaskFormActions.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private Rectangle2D handleImageMask(Mask mask, AffineTransform i2m) { RenderedImage image = mask.getSourceImage().getImage(0); final int minTileX = image.getMinTileX(); final int minTileY = image.getMinTileY(); final int numXTiles = image.getNumXTiles(); final int numYTiles = image.getNumYTiles(); final int width = image.getWidth(); final int height = image.getHeight(); int minX = width; int maxX = 0; int minY = height; int maxY = 0; for (int tileX = minTileX; tileX < minTileX + numXTiles; ++tileX) { for (int tileY = minTileY; tileY < minTileY + numYTiles; ++tileY) { final Raster data = image.getTile(tileX, tileY); for (int x = data.getMinX(); x < data.getMinX() + data.getWidth(); x++) { for (int y = data.getMinY(); y < data.getMinY() + data.getHeight(); y++) { if (data.getSample(x, y, 0) != 0) { minX = Math.min(x, minX); maxX = Math.max(x, maxX); minY = Math.min(y, minY); maxY = Math.max(y, maxY); } } } } } Rectangle rect = new Rectangle(minX, minY, maxX - minX + 1, maxY - minY + 1); if (rect.isEmpty()) { return null; } else { return i2m.createTransformedShape(rect).getBounds2D(); } }
Example 3
Source File: ExportMaskPixelsAction.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private static long getNumMaskPixels(final RenderedImage maskImage, int sceneRasterWidth, int sceneRasterHeight) { final int minTileX = maskImage.getMinTileX(); final int minTileY = maskImage.getMinTileY(); final int numXTiles = maskImage.getNumXTiles(); final int numYTiles = maskImage.getNumYTiles(); final Rectangle imageRect = new Rectangle(0, 0, sceneRasterWidth, sceneRasterHeight); long numMaskPixels = 0; for (int tileX = minTileX; tileX < minTileX + numXTiles; ++tileX) { for (int tileY = minTileY; tileY < minTileY + numYTiles; ++tileY) { final Rectangle tileRectangle = new Rectangle(maskImage.getTileGridXOffset() + tileX * maskImage.getTileWidth(), maskImage.getTileGridYOffset() + tileY * maskImage.getTileHeight(), maskImage.getTileWidth(), maskImage.getTileHeight()); final Rectangle r = imageRect.intersection(tileRectangle); if (!r.isEmpty()) { Raster maskTile = maskImage.getTile(tileX, tileY); for (int y = r.y; y < r.y + r.height; y++) { for (int x = r.x; x < r.x + r.width; x++) { if (maskTile.getSample(x, y, 0) != 0) { numMaskPixels++; } } } } } } return numMaskPixels; }
Example 4
Source File: GIFImageWriter.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { if (abortRequested()) { processWriteAborted(); return; } processImageProgress((numRowsWritten*100.0F)/dh); } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 5
Source File: GIFImageWriter.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { if (abortRequested()) { processWriteAborted(); return; } processImageProgress((numRowsWritten*100.0F)/dh); } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 6
Source File: GIFImageWriter.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { if (abortRequested()) { processWriteAborted(); return; } processImageProgress((numRowsWritten*100.0F)/dh); } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 7
Source File: GIFImageWriter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { if (abortRequested()) { processWriteAborted(); return; } processImageProgress((numRowsWritten*100.0F)/dh); } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 8
Source File: GIFImageWriter.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { if (abortRequested()) { processWriteAborted(); return; } processImageProgress((numRowsWritten*100.0F)/dh); } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 9
Source File: GIFImageWriter.java From hottub with GNU General Public License v2.0 | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { if (abortRequested()) { processWriteAborted(); return; } processImageProgress((numRowsWritten*100.0F)/dh); } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 10
Source File: GIFImageWriter.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { if (abortRequested()) { processWriteAborted(); return; } processImageProgress((numRowsWritten*100.0F)/dh); } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 11
Source File: GIFImageWriter.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { processImageProgress((numRowsWritten*100.0F)/dh); if (abortRequested()) { processWriteAborted(); return; } } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 12
Source File: GIFImageWriter.java From Bytecoder with Apache License 2.0 | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { processImageProgress((numRowsWritten*100.0F)/dh); if (abortRequested()) { processWriteAborted(); return; } } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 13
Source File: GIFImageWriter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { if (abortRequested()) { processWriteAborted(); return; } processImageProgress((numRowsWritten*100.0F)/dh); } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 14
Source File: GIFImageWriter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { if (abortRequested()) { processWriteAborted(); return; } processImageProgress((numRowsWritten*100.0F)/dh); } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 15
Source File: GIFImageWriter.java From JDKSourceCode1.8 with MIT License | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { if (abortRequested()) { processWriteAborted(); return; } processImageProgress((numRowsWritten*100.0F)/dh); } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 16
Source File: GIFImageWriter.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { if (abortRequested()) { processWriteAborted(); return; } processImageProgress((numRowsWritten*100.0F)/dh); } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 17
Source File: GIFImageWriter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { if (abortRequested()) { processWriteAborted(); return; } processImageProgress((numRowsWritten*100.0F)/dh); } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 18
Source File: GIFImageWriter.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private void writeRows(RenderedImage image, LZWCompressor compressor, int sx, int sdx, int sy, int sdy, int sw, int dy, int ddy, int dw, int dh, int numRowsWritten, int progressReportRowPeriod) throws IOException { if (DEBUG) System.out.println("Writing unoptimized"); int[] sbuf = new int[sw]; byte[] dbuf = new byte[dw]; Raster raster = image.getNumXTiles() == 1 && image.getNumYTiles() == 1 ? image.getTile(0, 0) : image.getData(); for (int y = dy; y < dh; y += ddy) { if (numRowsWritten % progressReportRowPeriod == 0) { if (abortRequested()) { processWriteAborted(); return; } processImageProgress((numRowsWritten*100.0F)/dh); } raster.getSamples(sx, sy, sw, 1, 0, sbuf); for (int i = 0, j = 0; i < dw; i++, j += sdx) { dbuf[i] = (byte)sbuf[j]; } compressor.compress(dbuf, 0, dw); numRowsWritten++; sy += sdy; } }
Example 19
Source File: ExportMaskPixelsAction.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
/** * Writes all pixel values of the given product within the given Mask to the specified out. * * @param out the data output writer * @param product the product providing the pixel values * @param maskName the mask name * @param mustCreateHeader * @param mustExportTiePoints * @param mustExportWavelengthsAndSF * @param pm progress monitor * @return <code>true</code> for success, <code>false</code> if export has been terminated (by user) */ private static boolean exportMaskPixels(final PrintWriter out, final Product product, String maskName, boolean mustCreateHeader, boolean mustExportTiePoints, boolean mustExportWavelengthsAndSF, ProgressMonitor pm) throws IOException { final RenderedImage maskImage = product.getMaskGroup().get(maskName).getSourceImage(); final int minTileX = maskImage.getMinTileX(); final int minTileY = maskImage.getMinTileY(); final int numXTiles = maskImage.getNumXTiles(); final int numYTiles = maskImage.getNumYTiles(); final int w = product.getSceneRasterWidth(); final int h = product.getSceneRasterHeight(); final Rectangle imageRect = new Rectangle(0, 0, w, h); pm.beginTask("Writing pixel data...", numXTiles * numYTiles + 2); try { if (mustCreateHeader) { createHeader(out, product, maskName, mustExportWavelengthsAndSF); } pm.worked(1); writeColumnNames(out, product, maskName, mustExportTiePoints); pm.worked(1); for (int tileX = minTileX; tileX < minTileX + numXTiles; ++tileX) { for (int tileY = minTileY; tileY < minTileY + numYTiles; ++tileY) { if (pm.isCanceled()) { return false; } final Rectangle tileRectangle = new Rectangle(maskImage.getTileGridXOffset() + tileX * maskImage.getTileWidth(), maskImage.getTileGridYOffset() + tileY * maskImage.getTileHeight(), maskImage.getTileWidth(), maskImage.getTileHeight()); final Rectangle r = imageRect.intersection(tileRectangle); if (!r.isEmpty()) { Raster maskTile = maskImage.getTile(tileX, tileY); for (int y = r.y; y < r.y + r.height; y++) { for (int x = r.x; x < r.x + r.width; x++) { if (maskTile.getSample(x, y, 0) != 0) { writeDataLine(out, product, maskName, x, y, mustExportTiePoints); } } } } pm.worked(1); } } } finally { pm.done(); } return true; }