mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 03:55:28 -04:00
Better testing of source region reading. A few readers are failing for now, added @Ignore.
This commit is contained in:
parent
afff6f78a8
commit
8c93be05a5
@ -29,10 +29,13 @@
|
||||
package com.twelvemonkeys.imageio.plugins.svg;
|
||||
|
||||
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTestCase;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.imageio.spi.ImageReaderSpi;
|
||||
import java.awt.*;
|
||||
import java.awt.image.ImagingOpException;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@ -77,6 +80,7 @@ public class SVGImageReaderTestCase extends ImageReaderAbstractTestCase<SVGImage
|
||||
return Arrays.asList("image/svg+xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void testReadWithSizeParam() {
|
||||
try {
|
||||
@ -99,4 +103,11 @@ public class SVGImageReaderTestCase extends ImageReaderAbstractTestCase<SVGImage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Known issue: Source region reading not supported")
|
||||
@Override
|
||||
public void testReadWithSourceRegionParamEqualImage() throws IOException {
|
||||
super.testReadWithSourceRegionParamEqualImage();
|
||||
}
|
||||
}
|
@ -29,9 +29,12 @@
|
||||
package com.twelvemonkeys.imageio.plugins.wmf;
|
||||
|
||||
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTestCase;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.imageio.spi.ImageReaderSpi;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@ -76,4 +79,11 @@ public class WMFImageReaderTestCase extends ImageReaderAbstractTestCase<WMFImage
|
||||
protected List<String> getMIMETypes() {
|
||||
return Arrays.asList("image/x-wmf", "application/x-msmetafile");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Known issue: Source region reading not supported")
|
||||
@Override
|
||||
public void testReadWithSourceRegionParamEqualImage() throws IOException {
|
||||
super.testReadWithSourceRegionParamEqualImage();
|
||||
}
|
||||
}
|
@ -548,6 +548,44 @@ public abstract class ImageReaderAbstractTestCase<T extends ImageReader> {
|
||||
assertEquals("Read image has wrong height: " + image.getHeight(), 10, image.getHeight());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithSourceRegionParamEqualImage() throws IOException {
|
||||
// Default invocation
|
||||
assertReadWithSourceRegionParamEqualImage(new Rectangle(3, 3, 9, 9), getTestData().get(0), 0);
|
||||
}
|
||||
|
||||
protected void assertReadWithSourceRegionParamEqualImage(final Rectangle r, final TestData data, final int imageIndex) throws IOException {
|
||||
ImageReader reader = createReader();
|
||||
reader.setInput(data.getInputStream());
|
||||
ImageReadParam param = reader.getDefaultReadParam();
|
||||
|
||||
// Read full image and get sub image for comparison
|
||||
final BufferedImage roi = reader.read(imageIndex, param).getSubimage(r.x, r.y, r.width, r.height);
|
||||
|
||||
param.setSourceRegion(r);
|
||||
|
||||
final BufferedImage image = reader.read(imageIndex, param);
|
||||
|
||||
// try {
|
||||
// SwingUtilities.invokeAndWait(new Runnable() {
|
||||
// public void run() {
|
||||
// JPanel panel = new JPanel(new FlowLayout());
|
||||
// panel.add(new JLabel(new BufferedImageIcon(roi, r.width * 10, r.height * 10, true)));
|
||||
// panel.add(new JLabel(new BufferedImageIcon(image, r.width * 10, r.height * 10, true)));
|
||||
// JOptionPane.showConfirmDialog(null, panel);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
|
||||
assertNotNull("Image was null!", image);
|
||||
assertEquals("Read image has wrong width: " + image.getWidth(), r.width, image.getWidth());
|
||||
assertEquals("Read image has wrong height: " + image.getHeight(), r.height, image.getHeight());
|
||||
assertImageDataEquals("Images differ", roi, image);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadWithSizeAndSourceRegionParam() {
|
||||
// TODO: Is this test correct???
|
||||
|
@ -138,4 +138,11 @@ public class ICNSImageReaderTest extends ImageReaderAbstractTestCase {
|
||||
public void testReadWithSubsampleParamPixels() throws IOException {
|
||||
super.testReadWithSubsampleParamPixels();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Known issue: Source region reading not supported")
|
||||
@Override
|
||||
public void testReadWithSourceRegionParamEqualImage() throws IOException {
|
||||
super.testReadWithSourceRegionParamEqualImage();
|
||||
}
|
||||
}
|
||||
|
@ -2623,8 +2623,13 @@ public class PICTImageReader extends ImageReaderBase {
|
||||
Graphics2D g = image.createGraphics();
|
||||
try {
|
||||
// TODO: Might need to clear background
|
||||
|
||||
g.setTransform(AffineTransform.getScaleInstance(screenImageXRatio / subX, screenImageYRatio / subY));
|
||||
AffineTransform instance = new AffineTransform();
|
||||
if (pParam != null && pParam.getSourceRegion() != null) {
|
||||
Rectangle rectangle = pParam.getSourceRegion();
|
||||
instance.translate(-rectangle.x, -rectangle.y);
|
||||
}
|
||||
instance.scale(screenImageXRatio / subX, screenImageYRatio / subY);
|
||||
g.setTransform(instance);
|
||||
// try {
|
||||
drawOnto(g);
|
||||
// }
|
||||
|
Loading…
x
Reference in New Issue
Block a user