Package java.awt.image

Examples of java.awt.image.DataBufferDouble


  private void testGetData2(TestHarness harness) {
    harness.checkPoint("getData(int)")

    double[][] source = new double[][] {{1, 2}, {3, 4}};
    DataBufferDouble b = new DataBufferDouble(source, 2);
    double[] data = b.getData(1);
    harness.check(data.length == 2);
    harness.check(data[0] == 3);
    harness.check(data[1] == 4);

    // test where supplied array is bigger than 'size'
    source = new double[][] {{1, 2, 3}, {4, 5, 6}};
    b = new DataBufferDouble(source, 2);
    data = b.getData(1);
    harness.check(data.length == 3);
    harness.check(data[0] == 4);
    harness.check(data[1] == 5);
    harness.check(data[2] == 6);

    // test where offsets are specified
    source = new double[][] {{1, 2, 3, 4}, {5, 6, 7, 8}};
    b = new DataBufferDouble(source, 2, new int[] {1, 2});
    data = b.getData(1);
    harness.check(data.length == 4);
    harness.check(data[0] == 5);
    harness.check(data[1] == 6);
    harness.check(data[2] == 7);
    harness.check(data[3] == 8);

    // does a change to the source affect the DataBuffer? Yes
    source[1][2] = 99;
    harness.check(data[2] == 99);

    // check bounds exceptions
    boolean pass = true;
    try
    {
      b.getData(-1);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);

    pass = false;
    try
    {
      b.getData(2);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here


  implements Testlet
{
  public void test(TestHarness h)
  {
    // Check #1.
    h.check(new DataBufferDouble(5).getDataType(), DataBuffer.TYPE_DOUBLE);
  }
View Full Code Here

  private void testSetElem1(TestHarness harness) {
    harness.checkPoint("setElem(int, int)")

    double[] source = new double[] {1, 2};
    DataBufferDouble b = new DataBufferDouble(source, 2);
    b.setElem(1, 99);
    harness.check(b.getElem(1) == 99);

    // does the source array get updated? Yes
    harness.check(source[1] == 99);

    // test with offsets
    source = new double[] {1, 2, 3, 4, 5};
    b = new DataBufferDouble(source, 4, 1);
    harness.check(b.getElem(1) == 3);
    b.setElem(1, 99);
    harness.check(b.getElem(1) == 99);
    harness.check(source[2] == 99);

    boolean pass = false;
    try
    {
      b.setElem(-2, 99);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);

    pass = false;
    try
    {
      b.setElem(4, 99);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

  private void testSetElem2(TestHarness harness) {
    harness.checkPoint("setElem(int, int, int)");  

    double[][] source = new double[][] {{1, 2}, {3, 4}};
    DataBufferDouble b = new DataBufferDouble(source, 2);
    b.setElem(1, 1, 99);
    harness.check(b.getElem(1, 1) == 99);
    // does the source array get updated?
    harness.check(source[1][1] == 99);

    boolean pass = false;
    try
    {
      b.setElem(-1, 1, 99);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
    harness.check(pass);
 
    pass = false;
    try
    {
      b.setElem(2, 1, 99);
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

   */
  public void test(TestHarness harness)     
  {
    // check that array updates pass through
    double[][] data = new double[][] {{1, 2}};
    DataBufferDouble b = new DataBufferDouble(data, 2);
    double[][] banks = b.getBankData();
    harness.check(Arrays.equals(b.getBankData(), data));
    data[0][0] = 3;
    harness.check(banks[0][0] == 3);
    // test where supplied array is bigger than 'size'
    data = new double[][] {{1, 2, 3}};
    b = new DataBufferDouble(data, 2);
    banks = b.getBankData();
    harness.check(Arrays.equals(b.getBankData(), data));
    // test where offsets are specified
    data = new double[][] {{1, 2, 3}, {4, 5, 6, 7}};
    b = new DataBufferDouble(data, 2, new int[] {0, 1});
    banks = b.getBankData();
    harness.check(Arrays.equals(b.getBankData(), data));

    // check that a single bank buffer returns a valid array
    DataBufferDouble b2 = new DataBufferDouble(new double[] {1, 2}, 2);
    banks = b2.getBankData();
    harness.check(banks.length == 1);
    harness.check(banks[0][0] == 1);
    harness.check(banks[0][1] == 2);

    // check that a multi bank buffer returns a valid array
    DataBufferDouble b3 = new DataBufferDouble(new double[][] {{1}, {2}}, 1);
    banks = b3.getBankData();
    harness.check(banks.length == 2);
    harness.check(banks[0][0] == 1);
    harness.check(banks[1][0] == 2);
  }
View Full Code Here

  @Override
  protected DataBufferDouble createDataBuffer( final DoubleArray data )
  {
    final double[] sourceArray = data.getCurrentStorageArray();
    return new DataBufferDouble( sourceArray, sourceArray.length );
  }
View Full Code Here

     * @param scaledHeight the total image height in pixels (after prescaling, may be different than the "real" height)
     *
     * @return the tile argument
     */
    public Raster getTile(Raster tile, int subsample, int scaledWidth, int scaledHeight) throws IOException {
        DataBufferDouble dataBuffer = (DataBufferDouble) tile.getDataBuffer();
        double[] destArray = dataBuffer.getData();
        int tw = tile.getWidth(),
                th = tile.getHeight(),
                x0 = tile.getMinX(),
                y0 = tile.getMinY(),
                x1 = Math.min(x0 + tw - 1, scaledWidth - 1),
View Full Code Here

            // use the memory mapped buffer (faster)
            return getTile(tile, factor, tile.getWidth(), tile.getHeight());
        }

        // use the image tiler (slower)
        DataBufferDouble dataBuffer = (DataBufferDouble) tile.getDataBuffer();
        double[] destArray = dataBuffer.getData();
        int tw = tile.getWidth(),
                th = tile.getHeight(),
                w = tw * factor,
                h = th * factor,
                n,
View Full Code Here

        int offsets[] = new int[numBanks];
        for(int i = 0; i < numBanks; i++){
            offsets[i] = i;
        }

        db1 = new DataBufferDouble(dataArrays, size);
        db2 = new DataBufferDouble(dataArrays, size, offsets);
        db3 = new DataBufferDouble(dataArray, size);
        db4 = new DataBufferDouble(dataArray, size, numBanks);
        db5 = new DataBufferDouble(size);
        db6 = new DataBufferDouble(size, numBanks);
    }
View Full Code Here

        int offsets[] = new int[numBanks];
        for(int i = 0; i < numBanks; i++){
            offsets[i] = i;
        }

        db1 = new DataBufferDouble(dataArrays, size);
        db2 = new DataBufferDouble(dataArrays, size, offsets);
        db3 = new DataBufferDouble(dataArray, size);
        db4 = new DataBufferDouble(dataArray, size, numBanks);
        db5 = new DataBufferDouble(size);
        db6 = new DataBufferDouble(size, numBanks);
    }
View Full Code Here

TOP

Related Classes of java.awt.image.DataBufferDouble

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.