Java Code Examples for java.awt.image.WritableRaster#setSample()

The following examples show how to use java.awt.image.WritableRaster#setSample() . 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: PaletteBuilder.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
protected RenderedImage getIndexedImage() {
    IndexColorModel icm = getIndexColorModel();

    BufferedImage dst =
        new BufferedImage(src.getWidth(), src.getHeight(),
                          BufferedImage.TYPE_BYTE_INDEXED, icm);

    WritableRaster wr = dst.getRaster();
    for (int y =0; y < dst.getHeight(); y++) {
        for (int x = 0; x < dst.getWidth(); x++) {
            Color aColor = getSrcColor(x,y);
            wr.setSample(x, y, 0, findColorIndex(root, aColor));
        }
    }

    return dst;
}
 
Example 2
Source File: TransparencyTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
protected static BufferedImage createIndexedImage(int w, int h,
                                                  IndexColorModel icm)
{
    BufferedImage img = new BufferedImage(w, h,
                                          BufferedImage.TYPE_BYTE_INDEXED,
                                          icm);

    int mapSize = icm.getMapSize();
    int width = w / mapSize;

    WritableRaster wr = img.getRaster();
    for (int i = 0; i < mapSize; i++) {
        for (int y = 0; y < h; y++) {
            for (int x = 0; x < width; x++) {
                wr.setSample(i * width + x, y, 0, i);
            }
        }
    }
    return img;
}
 
Example 3
Source File: PaletteBuilder.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected RenderedImage getIndexedImage() {
    IndexColorModel icm = getIndexColorModel();

    BufferedImage dst =
        new BufferedImage(src.getWidth(), src.getHeight(),
                          BufferedImage.TYPE_BYTE_INDEXED, icm);

    WritableRaster wr = dst.getRaster();
    for (int y =0; y < dst.getHeight(); y++) {
        for (int x = 0; x < dst.getWidth(); x++) {
            Color aColor = getSrcColor(x,y);
            wr.setSample(x, y, 0, findColorIndex(root, aColor));
        }
    }

    return dst;
}
 
Example 4
Source File: CoverageUtilities.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
public static WritableRaster renderedImage2ShortWritableRaster( RenderedImage renderedImage, boolean nullBorders ) {
    int width = renderedImage.getWidth();
    int height = renderedImage.getHeight();

    Raster data = renderedImage.getData();
    WritableRaster writableRaster = createWritableRaster(width, height, Short.class, null, null);
    writableRaster.setRect(data);
    if (nullBorders) {
        for( int c = 0; c < width; c++ ) {
            writableRaster.setSample(c, 0, 0, shortNovalue);
            writableRaster.setSample(c, height - 1, 0, shortNovalue);
        }
        for( int r = 0; r < height; r++ ) {
            writableRaster.setSample(0, r, 0, shortNovalue);
            writableRaster.setSample(width - 1, r, 0, shortNovalue);
        }
    }
    return writableRaster;
}
 
Example 5
Source File: TransparencyTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected static BufferedImage createIndexedImage(int w, int h,
                                                  IndexColorModel icm)
{
    BufferedImage img = new BufferedImage(w, h,
                                          BufferedImage.TYPE_BYTE_INDEXED,
                                          icm);

    int mapSize = icm.getMapSize();
    int width = w / mapSize;

    WritableRaster wr = img.getRaster();
    for (int i = 0; i < mapSize; i++) {
        for (int y = 0; y < h; y++) {
            for (int x = 0; x < width; x++) {
                wr.setSample(i * width + x, y, 0, i);
            }
        }
    }
    return img;
}
 
Example 6
Source File: PaletteBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected RenderedImage getIndexedImage() {
    IndexColorModel icm = getIndexColorModel();

    BufferedImage dst =
        new BufferedImage(src.getWidth(), src.getHeight(),
                          BufferedImage.TYPE_BYTE_INDEXED, icm);

    WritableRaster wr = dst.getRaster();
    for (int y =0; y < dst.getHeight(); y++) {
        for (int x = 0; x < dst.getWidth(); x++) {
            Color aColor = getSrcColor(x,y);
            wr.setSample(x, y, 0, findColorIndex(root, aColor));
        }
    }

    return dst;
}
 
Example 7
Source File: CoverageUtilities.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a compatible {@link WritableRaster} from a {@link RenderedImage}.
 * 
 * @param renderedImage the image to convert.
 * @param nullBorders a flag that indicates if the borders should be set to null.
 * @return the converted writable raster.
 */
public static WritableRaster renderedImage2WritableRaster( RenderedImage renderedImage, boolean nullBorders ) {
    int width = renderedImage.getWidth();
    int height = renderedImage.getHeight();

    Raster data = renderedImage.getData();
    WritableRaster writableRaster = data.createCompatibleWritableRaster();
    writableRaster.setDataElements(0, 0, data);
    if (nullBorders) {
        for( int c = 0; c < width; c++ ) {
            writableRaster.setSample(c, 0, 0, doubleNovalue);
            writableRaster.setSample(c, height - 1, 0, doubleNovalue);
        }
        for( int r = 0; r < height; r++ ) {
            writableRaster.setSample(0, r, 0, doubleNovalue);
            writableRaster.setSample(width - 1, r, 0, doubleNovalue);
        }
    }

    return writableRaster;
}
 
Example 8
Source File: SimpleAbstractMergeStrategy.java    From geowave with Apache License 2.0 6 votes vote down vote up
protected void mergeRasters(
    final RasterTile<T> thisTile,
    final RasterTile<T> nextTile,
    final WritableRaster thisRaster,
    final WritableRaster nextRaster) {
  final int maxX = nextRaster.getMinX() + nextRaster.getWidth();
  final int maxY = nextRaster.getMinY() + nextRaster.getHeight();
  for (int b = 0; b < nextRaster.getNumBands(); b++) {
    for (int x = nextRaster.getMinX(); x < maxX; x++) {
      for (int y = nextRaster.getMinY(); y < maxY; y++) {
        final double thisSample = thisRaster.getSampleDouble(x, y, b);

        final double nextSample = nextRaster.getSampleDouble(x, y, b);
        thisRaster.setSample(x, y, b, getSample(x, y, b, thisSample, nextSample));
      }
    }
  }
}
 
Example 9
Source File: GeoWaveBasicCustomCRSRasterIT.java    From geowave with Apache License 2.0 5 votes vote down vote up
private void ingestGeneralPurpose(
    final String coverageName,
    final int tileSize,
    final double westLon,
    final double eastLon,
    final double southLat,
    final double northLat,
    final int numBands,
    final int numRasters,
    final RasterTileMergeStrategy<?> mergeStrategy) throws IOException {

  // just ingest a number of rasters
  final DataStore dataStore = dataStoreOptions.createDataStore();
  final RasterDataAdapter basicAdapter =
      RasterUtils.createDataAdapterTypeDouble(
          coverageName,
          numBands,
          tileSize,
          new NoDataMergeStrategy());
  final RasterDataAdapter mergeStrategyOverriddenAdapter =
      new RasterDataAdapter(basicAdapter, coverageName, mergeStrategy);
  basicAdapter.getMetadata().put("test-key", "test-value");
  dataStore.addType(mergeStrategyOverriddenAdapter, TestUtils.createWebMercatorSpatialIndex());
  try (Writer writer = dataStore.createWriter(mergeStrategyOverriddenAdapter.getTypeName())) {
    for (int r = 0; r < numRasters; r++) {
      final WritableRaster raster = RasterUtils.createRasterTypeDouble(numBands, tileSize);
      for (int x = 0; x < tileSize; x++) {
        for (int y = 0; y < tileSize; y++) {
          for (int b = 0; b < numBands; b++) {
            raster.setSample(x, y, b, TestUtils.getTileValue(x, y, b, r, tileSize));
          }
        }
      }
      writer.write(
          createCoverageTypeDouble(coverageName, westLon, eastLon, southLat, northLat, raster));
    }
  }
}
 
Example 10
Source File: CoverageUtilities.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a border of novalues.
 * 
 * @param raster the raster to process.
 */
public static void setNovalueBorder( WritableRaster raster ) {
    int width = raster.getWidth();
    int height = raster.getHeight();

    for( int c = 0; c < width; c++ ) {
        raster.setSample(c, 0, 0, doubleNovalue);
        raster.setSample(c, height - 1, 0, doubleNovalue);
    }
    for( int r = 0; r < height; r++ ) {
        raster.setSample(0, r, 0, doubleNovalue);
        raster.setSample(width - 1, r, 0, doubleNovalue);
    }
}
 
Example 11
Source File: AdditiveCompositeDouble.java    From mrgeo with Apache License 2.0 5 votes vote down vote up
@Override
public void compose(Raster src, Raster dstIn, WritableRaster dstOut)
{
  int minX = dstOut.getMinX();
  int minY = dstOut.getMinY();
  int maxX = minX + dstOut.getWidth();
  int maxY = minY + dstOut.getHeight();

  //log.debug("minX,minY,maxX,maxY: " + minX + "," + minY + "," + maxX + "," + maxY);
  for (int y = minY; y < maxY; y++)
  {
    for (int x = minX; x < maxX; x++)
    {
      double d = dstIn.getSampleDouble(x, y, 0);
      if (isNodataNaN)
      {
        if (Double.isNaN(d))
        {
          d = 0;
        }
      }
      else
      {
        if (FloatUtils.isEqual(d, nodata))
        {
          d = 0;
        }
      }
      double sample = (src.getSampleDouble(x, y, 0) * weight) + d;

      dstOut.setSample(x, y, 0, sample);
    }
  }
}
 
Example 12
Source File: CoverageUtilities.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create a subcoverage given a template coverage and an envelope.
 * 
 * @param template the template coverage used for the resolution.
 * @param subregion the envelope to extract to the new coverage. This should
 *                  be snapped on the resolution of the coverage, in order to avoid 
 *                  shifts.
 * @param value the value to set the new raster to, if not <code>null</code>. 
 * @param writableRasterHolder an array of length 1 to place the writable raster in, that 
 *                  was can be used to populate the coverage. If <code>null</code>, it is ignored.
 * @return the new coverage.
 */
public static GridCoverage2D createSubCoverageFromTemplate( GridCoverage2D template, Envelope2D subregion, Double value,
        WritableRaster[] writableRasterHolder ) {
    RegionMap regionMap = getRegionParamsFromGridCoverage(template);
    double xRes = regionMap.getXres();
    double yRes = regionMap.getYres();

    double west = subregion.getMinX();
    double south = subregion.getMinY();
    double east = subregion.getMaxX();
    double north = subregion.getMaxY();

    int cols = (int) ((east - west) / xRes);
    int rows = (int) ((north - south) / yRes);
    ComponentSampleModel sampleModel = new ComponentSampleModel(DataBuffer.TYPE_DOUBLE, cols, rows, 1, cols, new int[]{0});

    WritableRaster writableRaster = RasterFactory.createWritableRaster(sampleModel, null);
    if (value != null) {
        // autobox only once
        double v = value;
        for( int y = 0; y < rows; y++ ) {
            for( int x = 0; x < cols; x++ ) {
                writableRaster.setSample(x, y, 0, v);
            }
        }
    }
    if (writableRasterHolder != null)
        writableRasterHolder[0] = writableRaster;
    Envelope2D writeEnvelope = new Envelope2D(template.getCoordinateReferenceSystem(), west, south, east - west,
            north - south);
    GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);
    GridCoverage2D coverage2D = factory.create("newraster", writableRaster, writeEnvelope);
    return coverage2D;
}
 
Example 13
Source File: CoverageUtilities.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Transforms an array of values into a {@link WritableRaster}.
 * 
 * @param array the values to transform.
 * @param divide the factor by which to divide the values.
 * @param width the width of the resulting image.
 * @param height the height of the resulting image.
 * @return the raster.
 */
public static WritableRaster doubleArray2WritableRaster( double[] array, int width, int height ) {
    WritableRaster writableRaster = createWritableRaster(width, height, null, null, null);
    int index = 0;;
    for( int y = 0; y < height; y++ ) {
        for( int x = 0; x < width; x++ ) {
            writableRaster.setSample(x, y, 0, array[index++]);
        }
    }
    return writableRaster;
}
 
Example 14
Source File: CoverageUtilities.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Transforms an array of integer values into a {@link WritableRaster}.
 * 
 * @param array the values to transform.
 * @param divide the factor by which to divide the values.
 * @param width the width of the resulting image.
 * @param height the height of the resulting image.
 * @return the raster.
 */
public static WritableRaster integerArray2WritableRaster( int[] array, double divide, int width, int height ) {
    WritableRaster writableRaster = createWritableRaster(width, height, null, null, null);
    int index = 0;;
    for( int y = 0; y < height; y++ ) {
        for( int x = 0; x < width; x++ ) {
            double value = (double) array[index++] / divide;
            writableRaster.setSample(x, y, 0, value);
        }
    }
    return writableRaster;
}
 
Example 15
Source File: Canny.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
private WritableRaster createDoubleWritableRaster( int width, int height, int[] pixels ) {
    int dataType = DataBuffer.TYPE_DOUBLE;
    ComponentSampleModel sampleModel = new ComponentSampleModel(dataType, width, height, 1, width, new int[]{0});

    WritableRaster raster = RasterFactory.createWritableRaster(sampleModel, null);
    int index = 0;
    for( int y = 0; y < height; y++ ) {
        for( int x = 0; x < width; x++ ) {
            raster.setSample(x, y, 0, (double) pixels[index]);
            index++;
        }
    }
    return raster;
}
 
Example 16
Source File: BMPDecoder.java    From jclic with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Reads 24-bit uncompressed bitmap raster data.
 * @param lis the source input
 * @param infoHeader the <tt>InfoHeader</tt> structure, which was read using
 * {@link #readInfoHeader(net.sf.image4j.io.LittleEndianInputStream) readInfoHeader()}
 * @throws java.io.IOException if an error occurs
 * @return the decoded image read from the source input
 */
public static BufferedImage read24(InfoHeader infoHeader,
    net.sf.image4j.io.LittleEndianInputStream lis) throws IOException {
  //3 bytes per pixel
  //  blue 1
  //  green 1
  //  red 1
  // lines padded to nearest 32 bits
  // no alpha
  
  BufferedImage img = new BufferedImage(
      infoHeader.iWidth, infoHeader.iHeight,
      BufferedImage.TYPE_INT_RGB
      );
  
  WritableRaster raster = img.getRaster();
  
  //padding to nearest 32 bits
  int dataPerLine = infoHeader.iWidth * 3;
  int bytesPerLine = dataPerLine;
  if (bytesPerLine % 4 != 0) {
    bytesPerLine = (bytesPerLine / 4 + 1) * 4;
  }
  int padBytesPerLine = bytesPerLine - dataPerLine;
  
  for (int y = infoHeader.iHeight - 1; y >= 0; y--) {
    for (int x = 0; x < infoHeader.iWidth; x++) {
      int b = lis.readUnsignedByte();
      int g = lis.readUnsignedByte();
      int r = lis.readUnsignedByte();
      
      //int c = 0x00000000 | (r << 16) | (g << 8) | (b);
      //System.out.println(x + ","+y+"="+Integer.toHexString(c));
      //img.setRGB(x, y, c);
      raster.setSample(x, y, 0, r);
      raster.setSample(x, y, 1, g);
      raster.setSample(x, y, 2, b);
    }
    lis.skipBytes(padBytesPerLine);
  }
  
  return img;
}
 
Example 17
Source File: BufferedGridCoverageTest.java    From sis with Apache License 2.0 4 votes vote down vote up
/**
 * Tests with a two-dimensional coverage.
 */
@Test
public void testCoverage2D() {
    /*
     * Create coverage of 2×2 pixels with an identity "grid to CRS" transform.
     * The range of sample values will be [-10 … +10]°C.
     */
    final GridGeometry grid = new GridGeometry(new GridExtent(2, 2),
            PixelInCell.CELL_CENTER, MathTransforms.identity(2), HardCodedCRS.WGS84);

    final MathTransform1D toUnits = (MathTransform1D) MathTransforms.linear(0.5, 100);
    final SampleDimension sd = new SampleDimension.Builder().setName("t")
            .addQuantitative("data", NumberRange.create(-10, true, 10, true), toUnits, Units.CELSIUS)
            .build();
    /*
     * Create the grid coverage, gets its image and set values directly as short integers.
     */
    GridCoverage   coverage = new BufferedGridCoverage(grid, Arrays.asList(sd), DataBuffer.TYPE_SHORT);
    WritableRaster raster = ((BufferedImage) coverage.render(null)).getRaster();
    raster.setSample(0, 0, 0,   0);
    raster.setSample(1, 0, 0,   5);
    raster.setSample(0, 1, 0,  -5);
    raster.setSample(1, 1, 0, -10);
    /*
     * Verify packed values.
     */
    assertSamplesEqual(coverage, new double[][] {
        { 0,   5},
        {-5, -10}
    });
    /*
     * Verify converted values.
     */
    coverage = coverage.forConvertedValues(true);
    assertSamplesEqual(coverage, new double[][] {
        {100.0, 102.5},
        { 97.5,  95.0}
    });
    /*
     * Test writing converted values and verify the result in the packed coverage.
     * For example for the sample value at (0,0), we have (x is the packed value):
     *
     *   70 = x * 0.5 + 100   →   (70-100)/0.5 = x   →   x = -60
     */
    raster = ((BufferedImage) coverage.render(null)).getRaster();
    raster.setSample(0, 0, 0,  70);
    raster.setSample(1, 0, 0,   2.5);
    raster.setSample(0, 1, 0,  -8);
    raster.setSample(1, 1, 0, -90);
    assertSamplesEqual(coverage.forConvertedValues(false), new double[][] {
        { -60, -195},
        {-216, -380}
    });
}
 
Example 18
Source File: MinCompositeDouble.java    From mrgeo with Apache License 2.0 4 votes vote down vote up
@Override
public void compose(Raster src, Raster dstIn, WritableRaster dstOut)
{
  int minX = dstOut.getMinX();
  int minY = dstOut.getMinY();
  int maxX = minX + dstOut.getWidth();
  int maxY = minY + dstOut.getHeight();

  //log.debug("minX,minY,maxX,maxY: " + minX + "," + minY + "," + maxX + "," + maxY);
  for (int y = minY; y < maxY; y++)
  {
    for (int x = minX; x < maxX; x++)
    {
      double d = dstIn.getSampleDouble(x, y, 0);
      double s = src.getSampleDouble(x, y, 0) * weight;

      double sample;

      if (isNodataNaN)
      {
        if (Double.isNaN(d))
        {
          sample = s;
        }
        else if (Double.isNaN(s))
        {
          sample = d;
        }
        else if (s < d)
        {
          sample = s;
        }
        else
        {
          sample = d;
        }
      }
      else
      {
        if (FloatUtils.isEqual(d, nodata))
        {
          sample = s;
        }
        else if (FloatUtils.isEqual(s, nodata))
        {
          sample = d;
        }
        else if (s < d)
        {
          sample = s;
        }
        else
        {
          sample = d;
        }
      }

      dstOut.setSample(x, y, 0, sample);
    }
  }
}
 
Example 19
Source File: OmsMagnitudo.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
public void magnitudo( RandomIter flowIter, int width, int height, WritableRaster magWR ) {

        int[] flow = new int[2];
        // get rows and cols from the active region
        int cols = width;
        int rows = height;
        RandomIter magIter = RandomIterFactory.create(magWR, null);
        pm.beginTask(msg.message("magnitudo.workingon"), rows * 2); //$NON-NLS-1$

        for( int j = 0; j < rows; j++ ) {
            for( int i = 0; i < cols; i++ ) {
                flow[0] = i;
                flow[1] = j;
                // looks for the source
                if (isSourcePixel(flowIter, flow[0], flow[1])) {
                    magWR.setSample(flow[0], flow[1], 0, magIter.getSampleDouble(flow[0], flow[1], 0) + 1.0);
                    if (!go_downstream(flow, flowIter.getSampleDouble(flow[0], flow[1], 0)))
                        return;
                    while( !isNovalue(flowIter.getSampleDouble(flow[0], flow[1], 0))
                            && flowIter.getSampleDouble(flow[0], flow[1], 0) != 10 ) {
                        magWR.setSample(flow[0], flow[1], 0, magIter.getSampleDouble(flow[0], flow[1], 0) + 1.0);
                        if (!go_downstream(flow, flowIter.getSampleDouble(flow[0], flow[1], 0)))
                            return;
                    }

                    if (flowIter.getSampleDouble(flow[0], flow[1], 0) == 10) {
                        magWR.setSample(flow[0], flow[1], 0, magIter.getSampleDouble(flow[0], flow[1], 0) + 1.0);
                    }
                }
            }
            pm.worked(1);
        }

        for( int j = 0; j < rows; j++ ) {
            for( int i = 0; i < cols; i++ ) {
                if (magIter.getSampleDouble(i, j, 0) == 0.0 && flowIter.getSampleDouble(i, j, 0) == 10.0) {
                    magWR.setSample(i, j, 0, 1.0);
                } else if (magIter.getSampleDouble(i, j, 0) == 0.0 && isNovalue(flowIter.getSampleDouble(i, j, 0))) {
                    magWR.setSample(i, j, 0, doubleNovalue);
                }
            }
            pm.worked(1);
        }
        pm.done();
    }
 
Example 20
Source File: ModelsEngine.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Evaluate the shadow map.
 *
 * @param i
 *            the x axis index.
 * @param j
 *            the y axis index.
 * @param tmpWR
 *            the output shadow map.
 * @param demWR
 *            the elevation map.
 * @param res
 *            the resolution of the elevation map.
 * @param normalSunVector
 * @param inverseSunVector
 * @return
 */
private static WritableRaster shadow( int i, int j, WritableRaster tmpWR, WritableRaster demWR, double res,
        double[] normalSunVector, double[] inverseSunVector ) {
    int n = 0;
    double zcompare = -Double.MAX_VALUE;
    double dx = (inverseSunVector[0] * n);
    double dy = (inverseSunVector[1] * n);
    int nCols = tmpWR.getWidth();
    int nRows = tmpWR.getHeight();
    int idx = (int) Math.round(i + dx);
    int jdy = (int) Math.round(j + dy);
    double vectorToOrigin[] = new double[3];
    while( idx >= 0 && idx <= nCols - 1 && jdy >= 0 && jdy <= nRows - 1 ) {
        vectorToOrigin[0] = dx * res;
        vectorToOrigin[1] = dy * res;

        int tmpY = (int) (j + dy);
        if (tmpY < 0) {
            tmpY = 0;
        } else if (tmpY > nRows) {
            tmpY = nRows - 1;
        }
        int tmpX = (int) (i + dx);
        if (tmpX < 0) {
            tmpX = 0;
        } else if (tmpY > nCols) {
            tmpX = nCols - 1;
        }
        vectorToOrigin[2] = demWR.getSampleDouble(idx, jdy, 0);
        // vectorToOrigin[2] = (pitRandomIter.getSampleDouble(idx, jdy, 0) +
        // pitRandomIter
        // .getSampleDouble(tmpX, tmpY, 0)) / 2;
        double zprojection = scalarProduct(vectorToOrigin, normalSunVector);
        if ((zprojection < zcompare)) {
            tmpWR.setSample(idx, jdy, 0, 0);
        } else {
            zcompare = zprojection;
        }
        n = n + 1;
        dy = (inverseSunVector[1] * n);
        dx = (inverseSunVector[0] * n);
        idx = (int) Math.round(i + dx);
        jdy = (int) Math.round(j + dy);
    }
    return tmpWR;
}