AffineTransform, RescaleOp and Bilinear hint

Discussion in 'Java' started by news.skynet.be, Mar 25, 2005.

  1. Hello.

    I have written an application that manipulates images. It can rescale and
    make the image brighter working with BufferedImages and jpegs.

    I am using the AffineTransformOp() to physically scale the size of the image
    and the RescaleOp() to make it brighter.

    Both work fine UNLESS I apply the AffineTransform, first, with an
    interpolation rendering hint of bilinear. If I do this and then try to
    apply the RescaleOp after the image just goes to black.

    The RescaleOp works fine if I use the AffineTransform with and interpolatin
    of nearest neighbour, but I want to use bilenear.

    This is the code for the physical rescale:

    BufferedImageOp op = null;
    RenderingHints scaleHint = new
    RenderingHints(RenderingHints.KEY_INTERPOLATION,
    RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    //rescale the image
    op = new AffineTransformOp(AffineTransform.getScaleInstance(.75,
    ..75),scaleHint);
    //AffineTransformOp.TYPE_NEAREST_NEIGHBOR AffineTransformOp.TYPE_BILINEAR
    //get the image from the panel
    this.source = imageMed.getTheImage();

    //update the undo array
    this.imageMed.updateUndo(this.source);

    //now manipulate the image we have got from above
    this.scaled = op.filter(this.source, null);//here the source is the image
    int w = this.scaled.getWidth();
    int h = this.scaled.getHeight();
    //now paint the image back to the panel
    //this.imageMed.paintImageBack(source);
    this.imageMed.getImagePanel(this.scaled,w,h);

    Dimension scaledSize = new Dimension(w,h);
    this.imageMed.refreshScroll(scaledSize);


    And this is the code for the brightness
    BufferedImageOp bright = null;
    //RenderingHints hints = new
    RenderingHints(RenderingHints.KEY_ANTIALIASING,
    // RenderingHints.VALUE_ANTIALIAS_ON);

    //hints.put(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY
    );

    RenderingHints brightHint = new
    RenderingHints(RenderingHints.KEY_INTERPOLATION,
    RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    brightHint.put(RenderingHints.KEY_ALPHA_INTERPOLATION,
    RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT);
    brightHint.put(RenderingHints.KEY_COLOR_RENDERING,
    RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    brightHint.put(RenderingHints.KEY_RENDERING,
    RenderingHints.VALUE_RENDER_QUALITY);

    bright = new RescaleOp(1.25f, 1, brightHint);//make it brighter
    //get the image from the panel
    this.source = imageMed.getTheImage();

    //update the undo array
    this.imageMed.updateUndo(this.source);

    //now manipulate the image we have got from above
    this.toBright = bright.filter(source, null);//here the source is the image

    //now paint the image back to the panel
    this.imageMed.paintImageBack(this.toBright);

    This has me perplexed. It must be something to do with the bilinear hint as
    it functions fine with nearest neighbour.

    thanks for taking the time to read.
    cheers
    Martin

    --

    ------------------------------------
    Martin Thorpe
    Web Developer
    Non Stop Loop
    www.nonstoploop.net
    ------------------------------------
     
    news.skynet.be, Mar 25, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick
    Replies:
    2
    Views:
    774
    Thomas Weidenfeller
    Oct 8, 2003
  2. Raj
    Replies:
    2
    Views:
    1,967
  3. Tim Fitzpatrick

    Problems with BILINEAR/BICUBIC filters in PIL

    Tim Fitzpatrick, Jul 3, 2003, in forum: Python
    Replies:
    0
    Views:
    472
    Tim Fitzpatrick
    Jul 3, 2003
  4. bilinear or licubic

    , Oct 6, 2006, in forum: Java
    Replies:
    1
    Views:
    467
    Oliver Wong
    Oct 6, 2006
  5. Dangling Pointer
    Replies:
    8
    Views:
    1,056
    Roedy Green
    May 21, 2012
Loading...

Share This Page