cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geert Josten" <geert.jos...@daidalos.nl>
Subject RE: imageop-block in 2.2
Date Tue, 24 Oct 2006 07:55:22 GMT
Hi Niclas,

>  1. Rotation of images will not produce the expected result. 
> I never managed to figure out how to make it work, and 
> probably need to dig deeper into the Java2D stuff (not my ball game).

I have been experimenting myself with making the image reading rotate
images. I added this helper function, that does the tricky part. Note
that I decided to do rotation in steps of 90 degrees to keep things
simple.. ;-)

    /**
     * Returns the affine transform that implements the rotating.
     * 0 = no rotation
     * 1 = 90 degrees clockwise
     * 2 = 180 degrees
     * 3 = 90 degrees counterclockwise
     */
    private AffineTransform getRotateTransform(int r, double width,
double height) {
/*
A =   0 = (+x, +y)  1,  0,  0,  1
B =  90 = (+y, -x)  0,  1, -1,  0
C = 180 = (-x, -y) -1,  0,  0, -1
D = 270 = (-y, +x)  0, -1,  1,  0

        |
  D     |     A
        |
--------+--------
        |
  C     |     B
        |

Once rotated, the coordinates have to be shifted/translated out of the
negative quadrants into the positive one.
A => 0       0
B => height  0
C => width   height
D => 0       width
*/
        r = (r % 4);
        if (r == 1) {
            // B
            return new AffineTransform(0.0d, 1.0d, -1.0d, 0.0d, height,
0.0d);
            /* inversion? */
            //return new AffineTransform(0.0d, 1.0d, 1.0d, 0.0d, 0.0d,
0.0d);
        } else if (r == 2) {
            // C
            return new AffineTransform(-1.0d, 0.0d, 0.0d, -1.0d, width,
height);
        } else if (r == 3) {
            // D
            return new AffineTransform(0.0d, -1.0d, 1.0d, 0.0d, 0.0d,
width);
        } else {
            // A
            return new AffineTransform(1.0d, 0.0d, 0.0d, 1.0d, 0.0d,
0.0d);
        }
    }

Never got the time to commit this..

Grtz,
Geert
   
 
Drs. G.P.H. Josten
Consultant
 
 

Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665  JZ  Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
www.daidalos.nl
KvK 27164984


De informatie - verzonden in of met dit emailbericht - is afkomstig van Daidalos BV en is
uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen,
verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend.

Mime
View raw message