AffineTransform, RescaleOp and Bilinear hint

N

news.skynet.be

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
------------------------------------
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top