001 package org.mycore.services.imaging.JAI.imgOperation;
002
003 import javax.media.jai.PlanarImage;
004 import javax.media.jai.RenderedOp;
005
006
007 public class MCRJAIResizeOp extends MCRJAIScaleOp implements MCRJAIImageOp {
008 int newWidth;
009 int newHeight;
010
011 public MCRJAIResizeOp(int newWidth, int newHeight) {
012 super(1);
013
014 this.newWidth = newWidth;
015 this.newHeight = newHeight;
016 }
017
018 /* (non-Javadoc)
019 * @see org.mycore.services.imaging.MCRJAIImageOp#executeOp(javax.media.jai.PlanarImage)
020 */
021 public RenderedOp executeOp(PlanarImage image){
022 float xScale = (newWidth <= 0 )? 1.0F : (float) newWidth / (float) image.getWidth();
023 float yScale = (newHeight <= 0)? 1.0F : (float) newHeight / (float) image.getHeight();
024 scaleFactor = (yScale < xScale) ? yScale : xScale;
025
026 return scale(image, scaleFactor);
027 }
028 }