Added PNMImageWriterTest

This commit is contained in:
Harald Kuhr 2020-09-24 17:11:19 +02:00
parent 5040e9fe8a
commit f54f4370c0
3 changed files with 32 additions and 1 deletions

View File

@ -65,6 +65,7 @@ public final class PNMImageWriter extends ImageWriterBase {
@Override @Override
public void write(final IIOMetadata streamMetadata, final IIOImage image, final ImageWriteParam param) throws IOException { public void write(final IIOMetadata streamMetadata, final IIOImage image, final ImageWriteParam param) throws IOException {
assertOutput();
// TODO: Issue warning if streamMetadata is non-null? // TODO: Issue warning if streamMetadata is non-null?
// TODO: Issue warning if IIOImage contains thumbnails or other data we can't store? // TODO: Issue warning if IIOImage contains thumbnails or other data we can't store?

View File

@ -55,7 +55,8 @@ public class PNMImageReaderTest extends ImageReaderAbstractTest<PNMImageReader>
new TestData(getClassLoaderResource("/pgm/house.l.pgm"), new Dimension(367, 241)), // P5 (PGM RAW) new TestData(getClassLoaderResource("/pgm/house.l.pgm"), new Dimension(367, 241)), // P5 (PGM RAW)
new TestData(getClassLoaderResource("/ppm/lighthouse_rgb48.ppm"), new Dimension(768, 512)), // P6 (PPM RAW, 16 bits/sample) new TestData(getClassLoaderResource("/ppm/lighthouse_rgb48.ppm"), new Dimension(768, 512)), // P6 (PPM RAW, 16 bits/sample)
new TestData(getClassLoaderResource("/pam/lena.pam"), new Dimension(128, 128)), // P7 RGB new TestData(getClassLoaderResource("/pam/lena.pam"), new Dimension(128, 128)), // P7 RGB
new TestData(getClassLoaderResource("/pam/rgba.pam"), new Dimension(4, 2)) // P7 RGB_ALPHA new TestData(getClassLoaderResource("/pam/rgba.pam"), new Dimension(4, 2)), // P7 RGB_ALPHA
new TestData(getClassLoaderResource("/pfm/memorial.pfm"), new Dimension(512, 768)) // PF (32 bits/sample, floating point)
); );
} }

View File

@ -0,0 +1,29 @@
package com.twelvemonkeys.imageio.plugins.pnm;
import com.twelvemonkeys.imageio.util.ImageWriterAbstractTest;
import javax.imageio.ImageWriter;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.util.Arrays;
import java.util.List;
public class PNMImageWriterTest extends ImageWriterAbstractTest {
private final PNMImageWriterSpi provider = new PNMImageWriterSpi();
@Override
protected ImageWriter createImageWriter() {
return provider.createWriterInstance(null);
}
@Override
protected List<? extends RenderedImage> getTestData() {
return Arrays.asList(
new BufferedImage(100, 100, BufferedImage.TYPE_3BYTE_BGR),
new BufferedImage(100, 100, BufferedImage.TYPE_BYTE_GRAY),
new BufferedImage(100, 100, BufferedImage.TYPE_USHORT_GRAY),
new BufferedImage(100, 100, BufferedImage.TYPE_4BYTE_ABGR)
);
}
}