@SuppressWarnings({"deprecation"}) @Override public void onRegistration(final ServiceRegistry registry, final Class<?> category) { if (!WMF_READER_AVAILABLE) { IIOUtil.deregisterProvider(registry, this, category); } } }
@Override public void flush() throws IOException { // NOTE: The contract of OutputStream.flush is very different from ImageOutputStream.flush. We can't delegate. // TODO: Fulfill the contract of OutputStream.flush? This seems to be good enough for now. assertOpen(); }
public final int read(byte[] pBytes) throws IOException { return read(pBytes, 0, pBytes.length); }
@Test public void testCreateFromIndexedColorModel1to8() { for (int bits = 1; bits <= 8; bits <<= 1) { int[] colors = createIntLut(1 << bits); IndexColorModel colorModel = new IndexColorModel(bits, colors.length, colors, 0, false, -1, DataBuffer.TYPE_BYTE); assertEquals( IndexedImageTypeSpecifier.createFromIndexColorModel(colorModel), ImageTypeSpecifiers.createFromIndexColorModel(colorModel) ); } }
@Test public void testDisposeAfterRead() { ImageReader reader = createReader(); TestData data = getTestData().get(0); reader.setInput(data.getInputStream()); reader.dispose(); // Just pass with no exceptions }
@Test public void testCreateGrayscale32() { assertEquals( UInt32ImageTypeSpecifier.createInterleaved(GRAY, new int[] {0}, false, false), ImageTypeSpecifiers.createGrayscale(32, DataBuffer.TYPE_INT) ); }
@Test public void testCreateIndexedIntArray16() { int[] colors = createIntLut(1 << 16); assertEquals( IndexedImageTypeSpecifier.createFromIndexColorModel(new IndexColorModel(16, colors.length, colors, 0, false, -1, DataBuffer.TYPE_USHORT)), ImageTypeSpecifiers.createIndexed(colors, false, -1, 16, DataBuffer.TYPE_USHORT) ); }
@SuppressWarnings("unchecked") @Override public void onRegistration(final ServiceRegistry registry, final Class<?> category) { ImageReaderSpi defaultProvider = lookupProviderByName(registry, "com.sun.imageio.plugins.bmp.BMPImageReaderSpi", ImageReaderSpi.class); if (defaultProvider != null) { // Order before com.sun provider, to aid ImageIO in selecting our reader registry.setOrdering((Class<ImageReaderSpi>) category, this, defaultProvider); } }
/** * Creates an {@code InputStream} adapter that reads from an underlying {@code ImageInputStream}. * The input stream will read until the end of {@code pStream}. * * @param pStream the stream to read from. * @return an {@code InputStream} reading from {@code pStream}. */ public static InputStream createStreamAdapter(final ImageInputStream pStream) { // TODO: Include stream start pos? // TODO: Skip buffering for known in-memory implementations? return new BufferedInputStream(new IIOInputStreamAdapter(pStream)); }
@Test public void testProviderInstalledForNames() { Class<? extends ImageReader> readerClass = getReaderClass(); for (String name : getFormatNames()) { assertProviderInstalledForName(name, readerClass); } }
@Test public void testProviderInstalledForMIMETypes() { Class<? extends ImageReader> readerClass = getReaderClass(); for (String type : getMIMETypes()) { assertProviderInstalledForMIMEType(type, readerClass); } }
public static ImageTypeSpecifier createFromIndexColorModel(final IndexColorModel pColorModel) { return IndexedImageTypeSpecifier.createFromIndexColorModel(pColorModel); }
@Test public void testProviderInstalledForSuffixes() { Class<? extends ImageReader> readerClass = getReaderClass(); for (String suffix : getSuffixes()) { assertProviderInstalledForSuffix(suffix, readerClass); } }
public static ImageTypeSpecifier createInterleaved(final ColorSpace colorSpace, final int[] bandOffsets, final int dataType, final boolean hasAlpha, final boolean isAlphaPremultiplied) { // As the ComponentColorModel is broken for 32 bit unsigned int, we'll use our own version if (dataType == DataBuffer.TYPE_INT) { return UInt32ImageTypeSpecifier.createInterleaved(colorSpace, bandOffsets, hasAlpha, isAlphaPremultiplied); } // ...or fall back to default for anything else return ImageTypeSpecifier.createInterleaved(colorSpace, bandOffsets, dataType, hasAlpha, isAlphaPremultiplied); }
protected static Rectangle getSourceRegion(final ImageWriteParam pParam, final int pWidth, final int pHeight) { return IIOUtil.getSourceRegion(pParam, pWidth, pHeight); }
public int read(final byte[] pBytes, final int pOffset, final int pLength) throws IOException { if (hasLength && left <= 0) { return -1; } int read = input.read(pBytes, pOffset, (int) findMaxLen(pLength)); if (hasLength) { left = read < 0 ? 0 : left - read; } return read; }
@Test public void testCreateFromIndexedColorModel16() { int[] colors = createIntLut(1 << 16); IndexColorModel colorModel = new IndexColorModel(16, colors.length, colors, 0, false, -1, DataBuffer.TYPE_USHORT); assertEquals( IndexedImageTypeSpecifier.createFromIndexColorModel(colorModel), ImageTypeSpecifiers.createFromIndexColorModel(colorModel) ); }
@Test public void testCreateIndexedIntArray1to8() { for (int bits = 1; bits <= 8; bits <<= 1) { int[] colors = createIntLut(1 << bits); assertEquals( IndexedImageTypeSpecifier.createFromIndexColorModel(new IndexColorModel(bits, colors.length, colors, 0, false, -1, DataBuffer.TYPE_BYTE)), ImageTypeSpecifiers.createIndexed(colors, false, -1, bits, DataBuffer.TYPE_BYTE) ); } }
@Override public void write(final byte[] pBytes, final int pOffset, final int pLength) throws IOException { assertOpen(); output.write(pBytes, pOffset, pLength); }
@Override public void write(final byte[] pBytes) throws IOException { assertOpen(); output.write(pBytes); }