Skip to main content

Calculate new image width and image height

2 replies [Last post]
lmhoa
Offline
Joined: 2006-06-20
Points: 0

I'm working on an application that reads a image from file, applies AffineTransform including scale, shear and rotate parameters and then saves it to another image file. But the new image is lost some when I keep it the same size as the original image.

Question:
Is there any ways to calculate new image size which is depend on scale, shear and rotate parameters?

Thanks for any information you provide, whether links, pointers to books, or source code. It will be very much appreciated.

Hoa

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bae
Offline
Joined: 2005-03-02
Points: 0

I'd suggest to try getBounds2D() method of the AffineTransformOp.
It calculates the bounding box of the transformed destination.

Also, the method createCompatibleDestImage(src, destCM) could be
helpful: it creates destination image of correct size.

Thanks,
Andrew

lmhoa
Offline
Joined: 2006-06-20
Points: 0

Thanks very much for your help, Andrew. Both work and I'd prefer the second one.

Hoa