@Test(expected = IllegalArgumentException.class) public void testGetDestinationParamDestinationExceedsIntegerMax() throws IIOException { ImageReadParam param = new ImageReadParam(); param.setSourceRegion(new Rectangle(3 * Short.MAX_VALUE, 2 * Short.MAX_VALUE)); // 6 442 057 734 pixels ImageReaderBase.getDestination(param, TYPES.iterator(), 6 * Short.MAX_VALUE, 4 * Short.MAX_VALUE); // 25 768 230 936 pixels }
@Test public void testHandHotspotWithParam() throws IOException { ImageReadParam param = new ImageReadParam(); assertHotSpot(getTestData().get(0), param, new Point(15, 15)); }
@Test(expected = IIOException.class) public void testGetDestinationParamIllegalDestination() throws IIOException { ImageReadParam param = new ImageReadParam(); param.setDestination(new BufferedImage(21, 1, BufferedImage.TYPE_USHORT_565_RGB)); ImageReaderBase.getDestination(param, TYPES.iterator(), 42, 1); }
@Test public void testGetDestinationParamNoDestination() throws IIOException { BufferedImage destination = ImageReaderBase.getDestination(new ImageReadParam(), TYPES.iterator(), 42, 1); assertEquals(BufferedImage.TYPE_INT_RGB, destination.getType()); assertEquals(42, destination.getWidth()); assertEquals(1, destination.getHeight()); }
@Test public void testGetDestinationParamDestinationWider() throws IIOException { ImageReadParam param = new ImageReadParam(); param.setDestination(new BufferedImage(42, 1, BufferedImage.TYPE_INT_RGB)); BufferedImage destination = ImageReaderBase.getDestination(param, TYPES.iterator(), 3, 3); assertEquals(42, destination.getWidth()); assertEquals(1, destination.getHeight()); assertEquals(BufferedImage.TYPE_INT_RGB, destination.getType()); }
@Test public void testGetDestinationParamGoodDestination() throws IIOException { ImageReadParam param = new ImageReadParam(); param.setDestination(new BufferedImage(21, 1, BufferedImage.TYPE_INT_ARGB)); BufferedImage destination = ImageReaderBase.getDestination(param, TYPES.iterator(), 42, 1); assertEquals(BufferedImage.TYPE_INT_ARGB, destination.getType()); assertEquals(21, destination.getWidth()); assertEquals(1, destination.getHeight()); }
@Test public void testGetDestinationParamSourceRegionWider() throws IIOException { ImageReadParam param = new ImageReadParam(); param.setSourceRegion(new Rectangle(42, 1)); BufferedImage destination = ImageReaderBase.getDestination(param, TYPES.iterator(), 3, 3); assertEquals(3, destination.getWidth()); assertEquals(1, destination.getHeight()); assertEquals(TYPES.get(0).getBufferedImageType(), destination.getType()); }
@Test public void testGetDestinationParamSourceRegionTaller() throws IIOException { ImageReadParam param = new ImageReadParam(); param.setSourceRegion(new Rectangle(1, 42)); BufferedImage destination = ImageReaderBase.getDestination(param, TYPES.iterator(), 3, 3); assertEquals(1, destination.getWidth()); assertEquals(3, destination.getHeight()); assertEquals(TYPES.get(0).getBufferedImageType(), destination.getType()); }
@Test public void testGetDestinationParamDestinationTaller() throws IIOException { ImageReadParam param = new ImageReadParam(); param.setDestination(new BufferedImage(1, 42, BufferedImage.TYPE_INT_ARGB)); BufferedImage destination = ImageReaderBase.getDestination(param, TYPES.iterator(), 3, 3); assertEquals(1, destination.getWidth()); assertEquals(42, destination.getHeight()); assertEquals(BufferedImage.TYPE_INT_ARGB, destination.getType()); }
@Test public void testHandHotspotExplicitDestination() throws IOException { CURImageReader reader = createReader(); reader.setInput(getTestData().get(0).getInputStream()); BufferedImage image = reader.read(0); // Create dest image with same data, except properties... BufferedImage dest = new BufferedImage( image.getColorModel(), image.getRaster(), image.getColorModel().isAlphaPremultiplied(), null ); ImageReadParam param = new ImageReadParam(); param.setDestination(dest); assertHotSpot(getTestData().get(0), param, new Point(15, 15)); }
@Test public void testGetDestinationParamGoodDestinationTypeAlt() throws IIOException { ImageReadParam param = new ImageReadParam(); // In essence, this is the same as TYPE_INT_ARGB ImageTypeSpecifier type = ImageTypeSpecifier.createPacked(ColorSpace.getInstance(ColorSpace.CS_sRGB), 0xff0000, 0xff00, 0xff, 0xff000000, DataBuffer.TYPE_INT, false); param.setDestinationType(type); BufferedImage destination = ImageReaderBase.getDestination(param, TYPES.iterator(), 6, 7); assertEquals(BufferedImage.TYPE_INT_ARGB, destination.getType()); assertEquals(6, destination.getWidth()); assertEquals(7, destination.getHeight()); }
@Test public void testHasExplicitDestinationParamWithDestinationOffsetUnspecified() { ImageReadParam param = new ImageReadParam(); // getDestinationOffset should now return new Point(0, 0) assertFalse(ImageReaderBase.hasExplicitDestination(param)); }
@Test(expected = IIOException.class) public void testGetDestinationParamIllegalDestinationType() throws IIOException { ImageReadParam param = new ImageReadParam(); param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_BYTE_GRAY)); ImageReaderBase.getDestination(param, TYPES.iterator(), 6, 7); }
@Test public void testHasExplicitDestinationParamWithDestination() { ImageReadParam param = new ImageReadParam(); param.setDestination(new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_GRAY)); assertTrue(ImageReaderBase.hasExplicitDestination(param)); }
@Test(expected = IIOException.class) public void testGetDestinationParamIllegalDestinationTypeAlt() throws IIOException { ImageReadParam param = new ImageReadParam(); param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_BGR)); ImageReaderBase.getDestination(param, TYPES.iterator(), 6, 7); }
@Test public void testHasExplicitDestinationParamWithDestinationOffset() { ImageReadParam param = new ImageReadParam(); param.setDestinationOffset(new Point(42, 42)); assertTrue(ImageReaderBase.hasExplicitDestination(param)); }
@Test public void testHasExplicitDestinationParamWithDestinationOffsetOrigin() { ImageReadParam param = new ImageReadParam(); param.setDestinationOffset(new Point(0, 0)); assertFalse(ImageReaderBase.hasExplicitDestination(param)); } }
@Test public void testHasExplicitDestinationDefaultParam() { assertFalse(ImageReaderBase.hasExplicitDestination(new ImageReadParam())); }
@Test public void testGetDestinationParamGoodDestinationType() throws IIOException { ImageReadParam param = new ImageReadParam(); param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_ARGB)); BufferedImage destination = ImageReaderBase.getDestination(param, TYPES.iterator(), 6, 7); assertEquals(BufferedImage.TYPE_INT_ARGB, destination.getType()); assertEquals(6, destination.getWidth()); assertEquals(7, destination.getHeight()); }
@Test public void testHasExplicitDestinationParamWithDestinationType() { ImageReadParam param = new ImageReadParam(); param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_ARGB)); assertTrue(ImageReaderBase.hasExplicitDestination(param)); }