PICT metadata + PNTG support

This commit is contained in:
Harald Kuhr
2021-03-27 14:39:59 +01:00
parent bb650e5280
commit 967f8e6984
23 changed files with 812 additions and 126 deletions
@@ -0,0 +1,30 @@
package com.twelvemonkeys.imageio.plugins.pict;
import com.twelvemonkeys.imageio.plugins.pict.QuickTime.ImageDesc;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
import static org.junit.Assert.assertTrue;
/**
* QTBMPDecompressorTest.
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: QTBMPDecompressorTest.java,v 1.0 24/03/2021 haraldk Exp$
*/
public class QTBMPDecompressorTest {
@Test
public void canDecompress() {
QTDecompressor decompressor = new QTBMPDecompressor();
ImageDesc description = new ImageDesc();
description.compressorVendor = QuickTime.VENDOR_APPLE;
description.compressorIdentifer = "WRLE";
description.extraDesc = "....bmp ...something...".getBytes(StandardCharsets.UTF_8);
assertTrue(decompressor.canDecompress(description));
}
}
@@ -0,0 +1,52 @@
package com.twelvemonkeys.imageio.plugins.pict;
import com.twelvemonkeys.imageio.plugins.pict.QuickTime.ImageDesc;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
/**
* QTBMPDecompressorTest.
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: QTBMPDecompressorTest.java,v 1.0 24/03/2021 haraldk Exp$
*/
public class QTGenericDecompressorTest {
private ImageDesc createDescription(final String identifer, final String name, final int depth) {
ImageDesc description = new ImageDesc();
description.compressorVendor = QuickTime.VENDOR_APPLE;
description.compressorIdentifer = identifer;
description.compressorName = name;
description.depth = (short) depth;
return description;
}
@Test
public void canDecompressJPEG() {
QTDecompressor decompressor = new QTGenericDecompressor();
assertTrue(decompressor.canDecompress(createDescription("jpeg", "Photo - JPEG", 8)));
assertTrue(decompressor.canDecompress(createDescription("jpeg", "Photo - JPEG", 24)));
}
@Test
public void canDecompressPNG() {
QTDecompressor decompressor = new QTGenericDecompressor();
assertTrue(decompressor.canDecompress(createDescription("png ", "PNG", 8)));
assertTrue(decompressor.canDecompress(createDescription("png ", "PNG", 24)));
assertTrue(decompressor.canDecompress(createDescription("png ", "PNG", 32)));
}
@Test
public void canDecompressTIFF() {
QTDecompressor decompressor = new QTGenericDecompressor();
assertTrue(decompressor.canDecompress(createDescription("tiff", "TIFF", 8)));
assertTrue(decompressor.canDecompress(createDescription("tiff", "TIFF", 24)));
assertTrue(decompressor.canDecompress(createDescription("tiff", "TIFF", 32)));
}
}
@@ -0,0 +1,46 @@
package com.twelvemonkeys.imageio.plugins.pict;
import com.twelvemonkeys.imageio.plugins.pict.QuickTime.ImageDesc;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
/**
* QTBMPDecompressorTest.
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: QTBMPDecompressorTest.java,v 1.0 24/03/2021 haraldk Exp$
*/
public class QTRAWDecompressorTest {
private ImageDesc createDescription(int bitDepth) {
ImageDesc description = new ImageDesc();
description.compressorVendor = QuickTime.VENDOR_APPLE;
description.compressorIdentifer = "raw ";
description.depth = (short) bitDepth;
return description;
}
@Test
public void canDecompressRGB() {
QTDecompressor decompressor = new QTRAWDecompressor();
assertTrue(decompressor.canDecompress(createDescription(24)));
}
@Test
public void canDecompressRGBA() {
QTDecompressor decompressor = new QTRAWDecompressor();
assertTrue(decompressor.canDecompress(createDescription(32)));
}
@Test
public void canDecompressGray() {
QTDecompressor decompressor = new QTRAWDecompressor();
assertTrue(decompressor.canDecompress(createDescription(40)));
}
}
@@ -0,0 +1,65 @@
package com.twelvemonkeys.imageio.plugins.pntg;
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTest;
import javax.imageio.spi.ImageReaderSpi;
import javax.imageio.stream.ImageInputStream;
import java.awt.*;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* PNTGImageReaderTest.
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: PNTGImageReaderTest.java,v 1.0 23/03/2021 haraldk Exp$
*/
public class PNTGImageReaderTest extends ImageReaderAbstractTest<PNTGImageReader> {
@Override
protected ImageReaderSpi createProvider() {
return new PNTGImageReaderSpi();
}
@Override
protected List<TestData> getTestData() {
return Arrays.asList(new TestData(getClassLoaderResource("/mac/porsches.mac"), new Dimension(576, 720)),
new TestData(getClassLoaderResource("/mac/MARBLES.MAC"), new Dimension(576, 720)));
}
@Override
protected List<String> getFormatNames() {
return Arrays.asList("PNTG", "pntg");
}
@Override
protected List<String> getSuffixes() {
return Arrays.asList("mac", "pntg");
}
@Override
protected List<String> getMIMETypes() {
return Collections.singletonList("image/x-pntg");
}
@Override
public void testProviderCanRead() throws IOException {
// TODO: This a kind of hack...
// Currently, the provider don't claim to read the MARBLES.MAC image,
// as it lacks the MacBinary header and thus no way to identify format.
// We can still read it, so we'll include it in the other tests.
List<TestData> testData = getTestData().subList(0, 1);
for (TestData data : testData) {
ImageInputStream stream = data.getInputStream();
assertNotNull(stream);
assertTrue("Provider is expected to be able to decode data: " + data, provider.canDecodeInput(stream));
}
}
}
@@ -0,0 +1,17 @@
package com.twelvemonkeys.imageio.plugins.pntg;
import org.junit.Test;
/**
* PNTGMetadataTest.
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: PNTGMetadataTest.java,v 1.0 23/03/2021 haraldk Exp$
*/
public class PNTGMetadataTest {
@Test
public void testCreate() {
new PNTGMetadata();
}
}