aboutsummaryrefslogtreecommitdiffstats
path: root/src/scratchpad/testcases/org/apache/poi
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2018-10-21 20:49:03 +0000
committerAndreas Beeker <kiwiwings@apache.org>2018-10-21 20:49:03 +0000
commit82f118a7d70ae501ef8dec3baba2aa191ebe7a45 (patch)
tree1582bf4625cc38965184444638063cf415d63bf9 /src/scratchpad/testcases/org/apache/poi
parent17cc3bab08820fa178cba1c9d9166645d4b3ac5e (diff)
downloadpoi-82f118a7d70ae501ef8dec3baba2aa191ebe7a45.tar.gz
poi-82f118a7d70ae501ef8dec3baba2aa191ebe7a45.zip
#60656 - Support export file that contains emf and render it correctly
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/hemf@1844522 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad/testcases/org/apache/poi')
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hemf/usermodel/HemfPictureTest.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/scratchpad/testcases/org/apache/poi/hemf/usermodel/HemfPictureTest.java b/src/scratchpad/testcases/org/apache/poi/hemf/usermodel/HemfPictureTest.java
index 94be4712e5..cabe627f66 100644
--- a/src/scratchpad/testcases/org/apache/poi/hemf/usermodel/HemfPictureTest.java
+++ b/src/scratchpad/testcases/org/apache/poi/hemf/usermodel/HemfPictureTest.java
@@ -63,7 +63,8 @@ public class HemfPictureTest {
public void paint() throws IOException {
byte buf[] = new byte[50_000_000];
- final boolean writeLog = true;
+ final boolean writeLog = false;
+ final boolean dumpRecords = false;
final boolean savePng = true;
Set<String> passed = new HashSet<>();
@@ -101,6 +102,10 @@ public class HemfPictureTest {
}
}
+ if (dumpRecords) {
+ dumpRecords(emf);
+ }
+
Graphics2D g = null;
try {
Dimension2D dim = emf.getSize();
@@ -112,17 +117,23 @@ public class HemfPictureTest {
width *= 1500. / max;
height *= 1500. / max;
}
+ width = Math.ceil(width);
+ height = Math.ceil(height);
- BufferedImage bufImg = new BufferedImage((int)Math.ceil(width), (int)Math.ceil(height), BufferedImage.TYPE_INT_ARGB);
+ BufferedImage bufImg = new BufferedImage((int)width, (int)height, BufferedImage.TYPE_INT_ARGB);
g = bufImg.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+ g.setComposite(AlphaComposite.Clear);
+ g.fillRect(0, 0, (int)width, (int)height);
+ g.setComposite(AlphaComposite.Src);
+
emf.draw(g, new Rectangle2D.Double(0, 0, width, height));
- final File pngName = new File("build/tmp", etName.replaceFirst(".*"+"/", "").replace(".emf", ".png"));
+ final File pngName = new File("build/tmp", etName.replaceFirst(".+/", "").replace(".emf", ".png"));
if (savePng) {
ImageIO.write(bufImg, "PNG", pngName);
}