Java Code Examples for java.awt.image.Raster#getSamples()
The following examples show how to use
java.awt.image.Raster#getSamples() .
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: ImageParser.java From teamengine with Apache License 2.0 | 5 votes |
private static String checkTransparentNodata(BufferedImage buffImage, Node node) throws Exception { String transparentNodata = "NA"; boolean noData = false; boolean transparent = true; int[] bandIndexes = new int[4]; bandIndexes[0] = 3; // A bandIndexes[1] = 2; // B bandIndexes[2] = 1; // G bandIndexes[3] = 0; // R Raster raster = buffImage.getRaster(); int minx = raster.getMinX(); int maxx = minx + raster.getWidth(); int miny = raster.getMinY(); int maxy = miny + raster.getHeight(); int[][] bands = new int[bandIndexes.length][raster.getWidth()]; for (int y = miny; y < maxy; y++) { for (int i = 0; i < bandIndexes.length; i++) { raster.getSamples(minx, y, maxx, 1, bandIndexes[i], bands[i]); } for (int x = minx; x < maxx; x++) { int a = bands[0][x]; int b = bands[1][x]; int g = bands[2][x]; int r = bands[3][x]; if (b == 0 && g == 0 && r == 0) { noData = true; if (a != 0) { transparent = false; } } } } transparentNodata = (noData) ? (transparent) ? "true" : "false" : "NA"; return transparentNodata; }
Example 3
Source File: ProductExamples.java From snap-examples with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) { try { Product product = ProductIO.readProduct("C:/Projects/BEAM/data/MER_RR__1P_A.N1"); int width = product.getSceneRasterWidth(); int height = product.getSceneRasterHeight(); // the expression to be evaluated String expression = "not l2_flags.INVALID and not l1_flags.BRIGHT"; // allocate boolean mask values for a single scan line int[] maskLine = new int[width]; for (int y = 0; y < height; y++) { // read mask for each scan line MultiLevelImage multiLevelMaskImage = product.getMaskImage(expression, null); RenderedImage maskImage = multiLevelMaskImage.getImage(0); // get the full resolution Raster data = maskImage.getData(new Rectangle(0, 0, width, 1)); int firstChannelIndex = 0; data.getSamples(0, 0, width, 1, firstChannelIndex, maskLine); // process mask values contained in maskLine here // maskValue == 255 -> true // maskValue == 0 -> false // ... } product.dispose(); } catch (IOException e) { // handle error here... e.printStackTrace(); } }
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; } }