public void RotateFlip(RotateFlipType rotateFlipType) { awt.geom.AffineTransform tx; if (!(CurrentImage.NativeImage is image.BufferedImage)) { // TBD: This implementation is for raster formats only throw new NotImplementedException("Only raster formats are supported"); } switch (rotateFlipType) { case RotateFlipType.RotateNoneFlipNone: return; case RotateFlipType.Rotate90FlipNone: tx = awt.geom.AffineTransform.getRotateInstance(Math.PI / 2); tx.translate(0, -Height); break; case RotateFlipType.Rotate180FlipNone: tx = awt.geom.AffineTransform.getScaleInstance(-1, -1); tx.translate(-Width, -Height); break; case RotateFlipType.Rotate270FlipNone: tx = awt.geom.AffineTransform.getRotateInstance(-Math.PI / 2); tx.translate(-Width, 0); break; case RotateFlipType.RotateNoneFlipX: tx = awt.geom.AffineTransform.getScaleInstance(-1, 1); tx.translate(-Width, 0); break; case RotateFlipType.Rotate90FlipX: tx = awt.geom.AffineTransform.getRotateInstance(Math.PI / 2); tx.scale(1, -1); break; case RotateFlipType.Rotate180FlipX: tx = awt.geom.AffineTransform.getScaleInstance(1, -1); tx.translate(0, -Height); break; case RotateFlipType.Rotate270FlipX: tx = awt.geom.AffineTransform.getRotateInstance(Math.PI / 2); tx.scale(-1, 1); tx.translate(-Width, -Height); break; default: throw new ArgumentOutOfRangeException(); } image.AffineTransformOp op = new image.AffineTransformOp(tx, image.AffineTransformOp.TYPE_NEAREST_NEIGHBOR); CurrentImage.NativeImage = op.filter((BufferedImage)CurrentImage.NativeImage, null); }
public void RotateFlip (RotateFlipType rotateFlipType) { awt.geom.AffineTransform tx; if ( !(CurrentImage.NativeImage is image.BufferedImage) ) // TBD: This implementation is for raster formats only throw new NotImplementedException("Only raster formats are supported"); switch (rotateFlipType) { case RotateFlipType.RotateNoneFlipNone : return; case RotateFlipType.Rotate90FlipNone : tx = awt.geom.AffineTransform.getRotateInstance(Math.PI / 2); tx.translate( 0, -Height ); break; case RotateFlipType.Rotate180FlipNone : tx = awt.geom.AffineTransform.getScaleInstance(-1, -1); tx.translate( -Width, -Height ); break; case RotateFlipType.Rotate270FlipNone : tx = awt.geom.AffineTransform.getRotateInstance(-Math.PI / 2); tx.translate( -Width, 0 ); break; case RotateFlipType.RotateNoneFlipX : tx = awt.geom.AffineTransform.getScaleInstance(-1, 1); tx.translate( -Width, 0 ); break; case RotateFlipType.Rotate90FlipX : tx = awt.geom.AffineTransform.getRotateInstance(Math.PI / 2); tx.scale(1, -1); break; case RotateFlipType.Rotate180FlipX : tx = awt.geom.AffineTransform.getScaleInstance(1, -1); tx.translate( 0, -Height ); break; case RotateFlipType.Rotate270FlipX : tx = awt.geom.AffineTransform.getRotateInstance(Math.PI / 2); tx.scale(-1, 1); tx.translate( -Width, -Height ); break; default: throw new ArgumentOutOfRangeException(); } image.AffineTransformOp op = new image.AffineTransformOp(tx, image.AffineTransformOp.TYPE_NEAREST_NEIGHBOR); CurrentImage.NativeImage = op.filter((BufferedImage)CurrentImage.NativeImage, null); }