0

Hi I've trying to rotate a BufferedImage in Java but anything works fine. This is my code:

public void RotateImageNDegrees(String angulo){
        AffineTransform tx = new AffineTransform();

        tx.rotate(Double.parseDouble(angulo), bimage.getWidth() / 2, bimage.getHeight() / 2);

        AffineTransformOp op = new AffineTransformOp(tx,
        AffineTransformOp.TYPE_BILINEAR);
        bimage = op.filter(bimage, null); 

        drawImageInFrame(bimage);   //Use bimage width and height to paint in a Frame
}

The method "drawImageInFrame(bimage);" draws the image using bimage width and height to set the size of the JFrame.

This is what it returns:

http://i61.tinypic.com/2ic3590.jpg

But what I need is something like:

http://i59.tinypic.com/14l7wuu.jpg

Thanks everybody =D

Nestoraj
  • 722
  • 2
  • 6
  • 19

1 Answers1

1

just a guess but you'll probably have to re-size the frame to root(height^2 + width^2) on each side in order to accommodate the entire image since it seems to be displaying the image in a frame that is still the width and height of the unrotated image. Haven't tried it myself though.

Lee McFaul
  • 26
  • 4
  • Hi I've tried what you said setting the size (1000,1000) to make sure that it has enough space to draw but it still appears like this: http://i62.tinypic.com/2userkj.jpg I think that the problem is that it is taken negative values to draw. Thanks anyway =D – Nestoraj Nov 25 '14 at 16:11
  • I know this is an old post. But just to help future readers, I believe that the problem wasn't that the pixels were lost but that the pixels were offscreen. I believe you would have to shift the image's x and y values to make sure the rest is displayed. – Gigi Bayte 2 Oct 01 '17 at 01:29