Skip to main content

Jagged edges after rotation

2 replies [Last post]
masoodit24
Offline
Joined: 2006-01-31

Hi Everyone,

I am try to rotate an image and put it on a background image. Image is being rotated successfuly but jagging appears if i use an small angle to rotate. I am also setting the Antialiasing using Rendering hints...

Please respond.

Thanks,
Masood

Following is the Code:

RenderingHints renderHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);

renderHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

int value = 5;
int angle = (float)(value * (Math.PI/180.0F));

out = new BufferedImage(bsrc1.getWidth(), bsrc1.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = out.createGraphics();
g2.setRenderingHints(renderHints);

//draw bg image
g2.drawRenderedImage(bsrc1, null);

at = AffineTransform.getTranslateInstance(width1+86-34,height1-30);
at.rotate(angle,612/2,486/2);

g2.drawRenderedImage(bsrc2,at);

g2.dispose();

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sunflar
Offline
Joined: 2005-10-28

The ANTIALIASING RenderingHint only affects rasterization of shapes, not the filtering of transformed images. Use the INTERPOLATION hint to set BILINEAR or BICUBIC filtering and you should see much smoother image rotations.

jansan
Offline
Joined: 2005-02-24

I do not see where you are enabling antialiasing.

Try applying RenderingHints.VALUE_ANTIALIAS_ON like this:

RenderingHints renderHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

Jan