ImageTypeSpecifier type = types.next(); if (type.equals(imageType)) { foundIt = true; break;
@Test public void testEquals() { ImageTypeSpecifier spec = UInt32ImageTypeSpecifier.createInterleaved(sRGB, new int [] {0, 1, 2}, false, false); ImageTypeSpecifier other = UInt32ImageTypeSpecifier.createInterleaved(sRGB, new int [] {0, 1, 2}, false, false); ImageTypeSpecifier different = UInt32ImageTypeSpecifier.createInterleaved(sRGB, new int [] {0, 1, 2, 3}, true, false); // Equivalent, but broken, not equal ImageTypeSpecifier broken = ImageTypeSpecifier.createInterleaved(sRGB, new int [] {0, 1, 2}, DataBuffer.TYPE_INT, false, false); assertEquals(spec, other); assertEquals(other, spec); assertTrue(spec.equals(other)); assertTrue(other.equals(spec)); assertFalse(spec.equals(different)); assertFalse(different.equals(spec)); assertFalse(spec.equals(broken)); assertFalse(broken.equals(spec)); }
@Test public void testEquals() { IndexColorModel cm = new IndexColorModel(1, 2, new int[]{0xffffff, 0x00}, 0, false, -1, DataBuffer.TYPE_BYTE); ImageTypeSpecifier spec = IndexedImageTypeSpecifier.createFromIndexColorModel(cm); ImageTypeSpecifier other = IndexedImageTypeSpecifier.createFromIndexColorModel(cm); ImageTypeSpecifier different = IndexedImageTypeSpecifier.createFromIndexColorModel(new IndexColorModel(2, 2, new int[]{0xff00ff, 0x00, 0xff00ff, 0x00}, 0, false, -1, DataBuffer.TYPE_BYTE)); assertEquals(spec, other); assertEquals(other, spec); assertEquals(spec.hashCode(), other.hashCode()); assertTrue(spec.equals(other)); assertTrue(other.equals(spec)); // TODO: There is still a problem that IndexColorModel does not override equals, // so any model with the same number of bits, transparency, and transfer type will be treated as equal assertFalse(other.equals(different)); }
@Override @Test public void testGetTypeSpecifiers() throws IOException { final ImageReader reader = createReader(); for (TestData data : getTestData()) { reader.setInput(data.getInputStream()); ImageTypeSpecifier rawType = reader.getRawImageType(0); // As the JPEGImageReader we delegate to returns null for YCbCr, we'll have to do the same if (rawType == null && data.getInput().toString().contains("jpeg")) { continue; } assertNotNull(rawType); Iterator<ImageTypeSpecifier> types = reader.getImageTypes(0); assertNotNull(types); assertTrue(types.hasNext()); // TODO: This might fail even though the specifiers are obviously equal, if the // color spaces they use are not the SAME instance, as ColorSpace uses identity equals // and Interleaved ImageTypeSpecifiers are only equal if color spaces are equal... boolean rawFound = false; while (types.hasNext()) { ImageTypeSpecifier type = types.next(); if (type.equals(rawType)) { rawFound = true; break; } } assertTrue("ImageTypeSepcifier from getRawImageType should be in the iterator from getImageTypes", rawFound); } }
@Test public void testImageTypesLayers() throws IOException { PSDImageReader imageReader = createReader(); try (ImageInputStream stream = getTestData().get(3).getInputStream()) { imageReader.setInput(stream); int numImages = imageReader.getNumImages(true); for (int i = 0; i < numImages; i++) { ImageTypeSpecifier rawType = imageReader.getRawImageType(i); assertNotNull(rawType); Iterator<ImageTypeSpecifier> types = imageReader.getImageTypes(i); assertNotNull(types); assertTrue(types.hasNext()); boolean found = false; while (types.hasNext()) { ImageTypeSpecifier type = types.next(); if (!found && (rawType == type || rawType.equals(type))) { found = true; } } assertTrue("RAW image type not in type iterator", found); } } }
@Test public void testGetTypeSpecifiers() throws IOException { final ImageReader reader = createReader(); for (TestData data : getTestData()) { reader.setInput(data.getInputStream()); ImageTypeSpecifier rawType = reader.getRawImageType(0); if (rawType == null && allowsNullRawImageType()) { continue; } assertNotNull(rawType); Iterator<ImageTypeSpecifier> types = reader.getImageTypes(0); assertNotNull(types); assertTrue(types.hasNext()); // TODO: This might fail even though the specifiers are obviously equal, if the // color spaces they use are not the SAME instance, as ColorSpace uses identity equals // and Interleaved ImageTypeSpecifiers are only equal if color spaces are equal... boolean rawFound = false; while (types.hasNext()) { ImageTypeSpecifier type = types.next(); if (type.equals(rawType)) { rawFound = true; break; } } assertTrue("ImageTypeSepcifier from getRawImageType should be in the iterator from getImageTypes", rawFound); } reader.dispose(); }
/** * Returns whether an <code>ImageTypeSpecifier</code> may be used to read * in the image at a specified index. * * XXX */ private static boolean isCompatibleType(ImageTypeSpecifier imageType, ImageReader reader, int imageIndex) throws IOException { Iterator imageTypes = reader.getImageTypes(imageIndex); boolean foundIt = false; while (imageTypes.hasNext()) { ImageTypeSpecifier type = (ImageTypeSpecifier) imageTypes.next(); if (type.equals(imageType)) { foundIt = true; break; } } return foundIt; }
/** * Returns whether an <code>ImageTypeSpecifier</code> may be used to read * in the image at a specified index. * * XXX */ private static boolean isCompatibleType(ImageTypeSpecifier imageType, ImageReader reader, int imageIndex) throws IOException { Iterator imageTypes = reader.getImageTypes(imageIndex); boolean foundIt = false; while (imageTypes.hasNext()) { ImageTypeSpecifier type = (ImageTypeSpecifier) imageTypes.next(); if (type.equals(imageType)) { foundIt = true; break; } } return foundIt; }
ImageTypeSpecifier type = (ImageTypeSpecifier)imageTypes.next(); if (type.equals(imageType)) { foundIt = true; break;
ImageTypeSpecifier type = (ImageTypeSpecifier)imageTypes.next(); if (type.equals(imageType)) { foundIt = true; break;
ImageTypeSpecifier type = (ImageTypeSpecifier)imageTypes.next(); if (type.equals(imageType)) { foundIt = true; break;
ImageTypeSpecifier type = (ImageTypeSpecifier)imageTypes.next(); if (type.equals(imageType)) { foundIt = true; break;
ImageTypeSpecifier type = (ImageTypeSpecifier)imageTypes.next(); if (type.equals(imageType)) { foundIt = true; break;
ImageTypeSpecifier type = imageTypes.next(); if (type.equals(imageType)) { foundIt = true; break;
ImageTypeSpecifier type = (ImageTypeSpecifier)imageTypes.next(); if (type.equals(imageType)) { foundIt = true; break;
@Test public void testEquals() { ImageTypeSpecifier spec = UInt32ImageTypeSpecifier.createInterleaved(sRGB, new int [] {0, 1, 2}, false, false); ImageTypeSpecifier other = UInt32ImageTypeSpecifier.createInterleaved(sRGB, new int [] {0, 1, 2}, false, false); ImageTypeSpecifier different = UInt32ImageTypeSpecifier.createInterleaved(sRGB, new int [] {0, 1, 2, 3}, true, false); // Equivalent, but broken, not equal ImageTypeSpecifier broken = ImageTypeSpecifier.createInterleaved(sRGB, new int [] {0, 1, 2}, DataBuffer.TYPE_INT, false, false); assertEquals(spec, other); assertEquals(other, spec); assertTrue(spec.equals(other)); assertTrue(other.equals(spec)); assertFalse(spec.equals(different)); assertFalse(different.equals(spec)); assertFalse(spec.equals(broken)); assertFalse(broken.equals(spec)); }
public void testGetTypeSpecifiers() throws IOException { final ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); ImageTypeSpecifier rawType = reader.getRawImageType(0); assertNotNull(rawType); Iterator<ImageTypeSpecifier> types = reader.getImageTypes(0); assertNotNull(types); assertTrue(types.hasNext()); // TODO: This might fail even though the specifiers are obviously equal, if the // color spaces they use are not the SAME instance, as ColorSpace uses identity equals // and Interleaved ImageTypeSpecifiers are only equal if color spaces are equal... boolean rawFound = false; while (types.hasNext()) { ImageTypeSpecifier type = types.next(); if (type.equals(rawType)) { rawFound = true; break; } } assertTrue("ImageTypeSepcifier from getRawImageType should be in the iterator from getImageTypes", rawFound); }
@Test public void testEquals() { IndexColorModel cm = new IndexColorModel(1, 2, new int[]{0xffffff, 0x00}, 0, false, -1, DataBuffer.TYPE_BYTE); ImageTypeSpecifier spec = IndexedImageTypeSpecifier.createFromIndexColorModel(cm); ImageTypeSpecifier other = IndexedImageTypeSpecifier.createFromIndexColorModel(cm); ImageTypeSpecifier different = IndexedImageTypeSpecifier.createFromIndexColorModel(new IndexColorModel(2, 2, new int[]{0xff00ff, 0x00, 0xff00ff, 0x00}, 0, false, -1, DataBuffer.TYPE_BYTE)); assertEquals(spec, other); assertEquals(other, spec); assertEquals(spec.hashCode(), other.hashCode()); assertTrue(spec.equals(other)); assertTrue(other.equals(spec)); // TODO: There is still a problem that IndexColorModel does not override equals, // so any model with the same number of bits, transparency, and transfer type will be treated as equal assertFalse(other.equals(different)); }
@Test public void testImageTypesLayers() throws IOException { PSDImageReader imageReader = createReader(); try (ImageInputStream stream = getTestData().get(3).getInputStream()) { imageReader.setInput(stream); int numImages = imageReader.getNumImages(true); for (int i = 0; i < numImages; i++) { ImageTypeSpecifier rawType = imageReader.getRawImageType(i); assertNotNull(rawType); Iterator<ImageTypeSpecifier> types = imageReader.getImageTypes(i); assertNotNull(types); assertTrue(types.hasNext()); boolean found = false; while (types.hasNext()) { ImageTypeSpecifier type = types.next(); if (!found && (rawType == type || rawType.equals(type))) { found = true; } } assertTrue("RAW image type not in type iterator", found); } } }
@Test public void testGetTypeSpecifiers() throws IOException { final ImageReader reader = createReader(); for (TestData data : getTestData()) { reader.setInput(data.getInputStream()); ImageTypeSpecifier rawType = reader.getRawImageType(0); if (rawType == null && allowsNullRawImageType()) { continue; } assertNotNull(rawType); Iterator<ImageTypeSpecifier> types = reader.getImageTypes(0); assertNotNull(types); assertTrue(types.hasNext()); // TODO: This might fail even though the specifiers are obviously equal, if the // color spaces they use are not the SAME instance, as ColorSpace uses identity equals // and Interleaved ImageTypeSpecifiers are only equal if color spaces are equal... boolean rawFound = false; while (types.hasNext()) { ImageTypeSpecifier type = types.next(); if (type.equals(rawType)) { rawFound = true; break; } } assertTrue("ImageTypeSepcifier from getRawImageType should be in the iterator from getImageTypes", rawFound); } }