ResizeProcessor implements SinglebandImageProcessor<Float, FImage> { public static FImage resizeMaxArea(FImage image, int maxArea, ResizeFilterFunction filterf) { final int width = image.width; final int height = image.height; final int area = width * height; if (area < maxArea) { return image; } else { final double whRatio = (double) width / (double) height; final int newWidth = (int) Math.sqrt(maxArea * whRatio); final int newHeight = (int) (newWidth / whRatio); zoomInplace(image, newWidth, newHeight, filterf); return image; } } ResizeProcessor(Mode mode);  ResizeProcessor(float amount, ResizeFilterFunction ff);  ResizeProcessor(float newX, float newY, ResizeFilterFunction ff);  ResizeProcessor(float amount);  ResizeProcessor(float newX, float newY);  ResizeProcessor(int maxSize);  ResizeProcessor(int maxSizeArea, boolean area);  ResizeProcessor(int newX, int newY, boolean aspectRatio);  ResizeProcessor(int newX, int newY, boolean aspectRatio, ResizeFilterFunction filterf); @Override void processImage(FImage image); void setFilterFunction(ResizeFilterFunction filterFunction); static FImage resizeMax(FImage image, int maxDim, ResizeFilterFunction filterf); static FImage resizeMaxArea(FImage image, int maxArea, ResizeFilterFunction filterf); static FImage resizeMax(FImage image, int maxDim); static FImage resizeMaxArea(FImage image, int maxArea); static I doubleSize(I image); static FImage doubleSize(FImage image); static I halfSize(I image); static FImage halfSize(FImage image); static FImage resample(FImage in, int newX, int newY); static FImage resample(FImage in, int newX, int newY, boolean aspect); static FImage resample(FImage in, int newX, int newY, boolean aspect, ResizeFilterFunction filterf); static FImage zoomInplace(FImage in, int newX, int newY); static FImage zoomInplace(FImage in, int newX, int newY, ResizeFilterFunction filterf); static FImage zoom(FImage in, FImage dst, ResizeFilterFunction filterf); static FImage zoom(FImage in, Rectangle inRect, FImage dst, Rectangle dstRect); static FImage zoom(FImage in, Rectangle inRect, FImage dst, Rectangle dstRect, ResizeFilterFunction filterf); static final ResizeFilterFunction DEFAULT_FILTER; }
@Test public void testResizeMaxArea1() { FImage image = new FImage(100, 200); image = ResizeProcessor.resizeMaxArea(image, 5000); assertEquals(5000, image.height * image.width); assertEquals(100.0 / 200.0, (double) image.width / (double) image.height, 0.001); }
@Test public void testResizeMaxArea2() { FImage image = new FImage(200, 100); image = ResizeProcessor.resizeMaxArea(image, 5000); assertEquals(5000, image.height * image.width); assertEquals(200.0 / 100.0, (double) image.width / (double) image.height, 0.001); }
@Test public void testResizeMaxArea3() { FImage image = new FImage(2687, 3356); image = ResizeProcessor.resizeMaxArea(image, 3700000); assertTrue(3700000 > image.height * image.width); assertEquals(2687.0 / 3356.0, (double) image.width / (double) image.height, 0.001); }