Package java.awt.image

Examples of java.awt.image.DataBufferFloat


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

    float[][] source = new float[][] {{1, 2}, {3, 4}};
    DataBufferFloat b = new DataBufferFloat(source, 2);
    float[] 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 float[][] {{1, 2, 3}, {4, 5, 6}};
    b = new DataBufferFloat(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 float[][] {{1, 2, 3, 4}, {5, 6, 7, 8}};
    b = new DataBufferFloat(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 DataBufferFloat(5).getDataType(), DataBuffer.TYPE_FLOAT);
  }
View Full Code Here

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

    float[] source = new float[] {1, 2};
    DataBufferFloat b = new DataBufferFloat(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 float[] {1, 2, 3, 4, 5};
    b = new DataBufferFloat(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)");  

    float[][] source = new float[][] {{1, 2}, {3, 4}};
    DataBufferFloat b = new DataBufferFloat(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
    float[][] data = new float[][] {{1, 2}};
    DataBufferFloat b = new DataBufferFloat(data, 2);
    float[][] 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 float[][] {{1, 2, 3}};
    b = new DataBufferFloat(data, 2);
    banks = b.getBankData();
    harness.check(Arrays.equals(b.getBankData(), data));
  
    // test where offsets are specified
    data = new float[][] {{1, 2, 3}, {4, 5, 6, 7}};
    b = new DataBufferFloat(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
    DataBufferFloat b2 = new DataBufferFloat(new float[] {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
    DataBufferFloat b3 = new DataBufferFloat(new float[][] {{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 DataBufferFloat createDataBuffer( final FloatArray data )
  {
    final float[] sourceArray = data.getCurrentStorageArray();
    return new DataBufferFloat( 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 {
        DataBufferFloat dataBuffer = (DataBufferFloat) tile.getDataBuffer();
        float[] 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)
        DataBufferFloat dataBuffer = (DataBufferFloat) tile.getDataBuffer();
        float[] 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 DataBufferFloat(dataArrays, size);
        db2 = new DataBufferFloat(dataArrays, size, offsets);
        db3 = new DataBufferFloat(dataArray, size);
        db4 = new DataBufferFloat(dataArray, size, numBanks);
        db5 = new DataBufferFloat(size);
        db6 = new DataBufferFloat(size, numBanks);
    }
View Full Code Here

    // Blitting from Buffered Image (INT RGB) to Custom Raster
    // (Float Data Buffer)
    public final void test_from_BuffImg_to_FloatDataBuffer(){
        src = createImage(BufferedImage.TYPE_INT_RGB);

        DataBufferFloat dbf = new DataBufferFloat(w * h * 3);
        int offsets[] = new int[]{0,1,2};
        ComponentSampleModel csm = new ComponentSampleModel(DataBuffer.TYPE_FLOAT,
                w, h, 3, 3 * w, offsets);
        WritableRaster wr = new OrdinaryWritableRaster(csm, dbf, new Point(0, 0));
        ColorModel cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), false, false, Transparency.OPAQUE, DataBuffer.TYPE_FLOAT);
View Full Code Here

TOP

Related Classes of java.awt.image.DataBufferFloat

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.