Package java.awt.image

Examples of java.awt.image.RescaleOp


  public void testConstructor2(TestHarness harness)
  {
    harness.checkPoint("(float, float, RenderingHints)");

    // Simple test
    RescaleOp op = new RescaleOp(2f, 6.5f, null);
   
    harness.check(Arrays.equals(op.getScaleFactors(null), new float[]{2f}));
    harness.check(Arrays.equals(op.getOffsets(null), new float[]{6.5f}));
    harness.check(op.getRenderingHints(), null);
   
    // Negative values
    try
    {
      op = new RescaleOp(-5f, -2f, null);
      harness.check(true);
    }
    catch (IllegalArgumentException ex)
    {
      harness.check(false);
View Full Code Here


{
  public void test(TestHarness harness)
  {
    RenderingHints r = new RenderingHints(RenderingHints.KEY_COLOR_RENDERING,
            RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    RescaleOp op = new RescaleOp(1, 1, r);
    harness.check(op.getRenderingHints() == r);
    op = new RescaleOp(1, 1, null);
    harness.check(op.getRenderingHints() == null);
  }
View Full Code Here

public class getScaleFactors implements Testlet
{
  public void test(TestHarness harness)
  {
    RescaleOp op = new RescaleOp(1, 1, null);
    harness.check(Arrays.equals(op.getScaleFactors(null), new float[]{1}));
   
    op = new RescaleOp(new float[]{1}, new float[]{1}, null);
    harness.check(Arrays.equals(op.getScaleFactors(null), new float[]{1}));
   
    float[] flt = new float[]{1, 2, 3, 4, 5};
    op = new RescaleOp(flt, flt, null);
    harness.check(op.getScaleFactors(null) != flt);
    harness.check(Arrays.equals(op.getScaleFactors(null),
                                new float[]{1, 2, 3, 4, 5}));
   
    // Mismatched array sizes...
    op = new RescaleOp(flt, new float[]{1, 2}, null);
    harness.check(op.getScaleFactors(null).length == 2);
    harness.check(op.getScaleFactors(null)[0] == 1);
    harness.check(op.getScaleFactors(null)[1] == 2);
   
    // Try passing in an array to be populated
    op = new RescaleOp(flt, flt, null);
    float[] arr = new float[5];
    harness.check(Arrays.equals(op.getScaleFactors(arr), arr));
    harness.check(Arrays.equals(arr, flt));
   
    // What if the array is too big?
    arr = new float[10];
    Arrays.fill(arr, 25);
    op.getScaleFactors(arr);
    for (int i = 0; i < 5; i++)
      harness.check(arr[i] == flt[i]);
    for (int i = 5; i < arr.length; i++)
      harness.check(arr[i] == 25);
   
    // What if array is too small?
    arr = new float[2];
    try
    {
      harness.check(op.getScaleFactors(arr).length == 2);
      harness.check(op.getScaleFactors(arr)[0] == 1);
      harness.check(op.getScaleFactors(arr)[1] == 2);
    }
    catch (ArrayIndexOutOfBoundsException ex)
    {
      harness.check(false);
    }
View Full Code Here

public class getPoint2D implements Testlet
{
  public void test(TestHarness harness)
  {
    RescaleOp op = new RescaleOp(1, 1, null);
    Point2D p = new Point2D.Double(1.0, 2.0);
    Point2D pp = new Point2D.Double();
    Point2D p1 = op.getPoint2D(p, pp);
    harness.check(p1, p);
    harness.check(p1 == pp);
    harness.check(p1 != p);
   
    // try null dest
    p1 = op.getPoint2D(p, null);
    harness.check(p1, p);
    harness.check(p1 != p);
   
    // try src == dst
    p1 = op.getPoint2D(p, p);
    harness.check(p1, p);
    harness.check(p1 == p);
  }
View Full Code Here

   */
  public void test(TestHarness harness)     
  {
    harness.checkPoint("getNumFactors");

    RescaleOp op = new RescaleOp(1.5f, 2.3f, null);
    harness.check(op.getNumFactors(), 1);
   
    op = new RescaleOp(new float[]{1.5f}, new float[]{2.3f}, null);
    harness.check(op.getNumFactors(), 1);
  
    op = new RescaleOp(new float[]{1.5f, 2.5f}, new float[]{2.3f, 6.6f}, null);
    harness.check(op.getNumFactors(), 2);
   
    op = new RescaleOp(new float[]{1.5f, 2.2f, 3.7f},
                       new float[]{2.3f, 2.3f, 2.3f},
                       null);
    harness.check(op.getNumFactors(), 3);
   
    op = new RescaleOp(new float[]{}, new float[]{}, null);
    harness.check(op.getNumFactors(), 0);
   
    // If the arrays are mismatched, return the lower value
    op = new RescaleOp(new float[]{1, 2, 3}, new float[]{1}, null);
    harness.check(op.getNumFactors(), 1);
    op = new RescaleOp(new float[]{1}, new float[]{1, 2, 3}, null);
    harness.check(op.getNumFactors(), 1);
    op = new RescaleOp(new float[]{1, 2}, new float[]{1, 2, 3}, null);
    harness.check(op.getNumFactors(), 2);
    op = new RescaleOp(new float[]{1, 2, 3}, new float[]{1, 2}, null);
    harness.check(op.getNumFactors(), 2);
  }
View Full Code Here

public class getOffsets implements Testlet
{
  public void test(TestHarness harness)
  {
    RescaleOp op = new RescaleOp(1, 1, null);
    harness.check(Arrays.equals(op.getOffsets(null), new float[]{1}));
   
    op = new RescaleOp(new float[]{1}, new float[]{1}, null);
    harness.check(Arrays.equals(op.getOffsets(null), new float[]{1}));
   
    float[] flt = new float[]{1, 2, 3, 4, 5};
    op = new RescaleOp(flt, flt, null);
    harness.check(op.getOffsets(null) != flt);
    harness.check(Arrays.equals(op.getOffsets(null),
                                new float[]{1, 2, 3, 4, 5}));
   
    // Mismatched array sizes...
    op = new RescaleOp(new float[]{1, 2}, flt, null);
    harness.check(op.getOffsets(null).length == 2);
    harness.check(op.getOffsets(null)[0] == 1);
    harness.check(op.getOffsets(null)[1] == 2);
   
    // Try passing in an array to be populated
    op = new RescaleOp(flt, flt, null);
    float[] arr = new float[5];
    harness.check(Arrays.equals(op.getOffsets(arr), arr));
    harness.check(Arrays.equals(arr, flt));
   
    // What if the array is too big?
    arr = new float[10];
    Arrays.fill(arr, 25);
    op.getOffsets(arr);
    for (int i = 0; i < 5; i++)
      harness.check(arr[i] == flt[i]);
    for (int i = 5; i < arr.length; i++)
      harness.check(arr[i] == 25);
   
    // What if array is too small?
    arr = new float[2];
    try
    {
      harness.check(op.getOffsets(arr).length == 2);
      harness.check(op.getOffsets(arr)[0] == 1);
      harness.check(op.getOffsets(arr)[1] == 2);
    }
    catch (ArrayIndexOutOfBoundsException ex)
    {
      harness.check(false);
    }
View Full Code Here

              tmpVisualGraphics.drawImage(picture.getVisualImage(), 0, 0, 320, editStatus.getPictureType().getHeight(), this);
 
              // Build a RescapeOp to perform the 50% transparency.
              float[] scales = { 1f, 1f, 1f, 0.5f };
              float[] offsets = new float[4];
              RescaleOp rop = new RescaleOp(scales, offsets, null);
 
              // Draw the visual screen on top of the priority screen with 50% transparency.
              offScreenGC.drawImage(tmpVisualImage, rop, 0, 0);
 
          } else {
View Full Code Here

                filterColor = true;
            }
        }

        if (filterColor) {
            this.colorFilter = new RescaleOp(scaleColor, offsetColor, null);
        }

        if (par.getParameterAsBoolean("grayscale", GRAYSCALE_DEFAULT)) {
            this.grayscaleFilter = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
        }
View Full Code Here

                filterColor = true;
            }
        }

        if (filterColor) {
            colorFilter = new RescaleOp(scaleColor, offsetColor, null);
        } else {
            colorFilter = null;
        }

        String grayscalePar = par.getParameter("grayscale", GRAYSCALE_DEFAULT);
View Full Code Here

     *            The graphics to draw on
     */
    private void draw(final Graphics2D graphics)
    {
      final float[] offsets = new float[4];
      final RescaleOp rop = new RescaleOp(scales, offsets, null);
      if (isHighlighted)
      {
        graphics.drawImage(getAnimal().highlightedImage, rop, location.x, location.y);
      }
      else
View Full Code Here

TOP

Related Classes of java.awt.image.RescaleOp

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.