Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AffineTransform inaccuracy or developer innaccuracy

 
marcus g.
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Concerning AffineTransforms. I understand that the order of operations matters on the AffineTransform itself such that matriceA * matriceB is not necessarily the same as matriceB * matriceA.

The problem comes when concatenating two transforms.

Method 1)
AffineTransform t = new AffineTransform();
t.scale(xxx);
t.rotate(xxx);
t.translate(xx);
image=op.filter(t,null);

which *I think* should behave the same as
Method 2)
AffineTransform scale = AffineTransform.getScaledInstance(xxx);
AffineTransform rotate= AffineTransform.getRotateInstance(xxx);
rotate.translate(xx);

scale.concatenate(rotate);
image =op.filter(scale,null);

Method 3) is to run op.filter after each transform using Method 2) only without concatenating the transforms. This is the only way I can be accurate.

Method 2) will usually put me off 100pixels without specifically trying to keep the aspect ratio.

Method 1) puts me way off.. In addition Method 1) and Method 2) leave a black box no matter which image height i use. I understand that when its rotated it should be rotate for a different image width and height after scaling.


Any ideas on this?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic