Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > AffineTransform, RescaleOp and Bilinear hint

Reply
Thread Tools

AffineTransform, RescaleOp and Bilinear hint

 
 
news.skynet.be
Guest
Posts: n/a
 
      03-25-2005
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,RenderingHi nts.VALUE_RENDER_QUALITY
);

RenderingHints brightHint = new
RenderingHints(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
brightHint.put(RenderingHints.KEY_ALPHA_INTERPOLAT ION,
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
------------------------------------


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bicubic interpolation suddenly is no better than bilinear. Dangling Pointer Java 8 05-21-2012 05:23 AM
bilinear or licubic cmk128@hotmail.com Java 1 10-06-2006 05:14 PM
Hint: Be smart and try this auctions site Jo65339@hotmail.com DVD Video 0 05-25-2006 05:10 PM
problem using JAI bilinear interpolation to scale a bufferedimage Raj Java 2 11-25-2003 11:52 AM
Problems with BILINEAR/BICUBIC filters in PIL Tim Fitzpatrick Python 0 07-03-2003 09:39 PM



Advertisments