You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by ss...@apache.org on 2017/09/18 15:02:41 UTC
svn commit: r1808726 -
/xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java
Author: ssteiner
Date: Mon Sep 18 15:02:41 2017
New Revision: 1808726
URL: http://svn.apache.org/viewvc?rev=1808726&view=rev
Log:
FOP-2739: Avoid rastering PDF with Smask to image
Modified:
xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java
Modified: xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java?rev=1808726&r1=1808725&r2=1808726&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java (original)
+++ xmlgraphics/commons/trunk/src/main/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java Mon Sep 18 15:02:41 2017
@@ -19,9 +19,13 @@
package org.apache.xmlgraphics.java2d.ps;
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.TexturePaint;
import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
import java.util.List;
/**
@@ -396,7 +400,7 @@ public class PSTilingPattern {
sb.append(width + " " + height + " 8 " + "matrix\n"); // width height bits/comp matrix
int [] argb = new int[width * height]; // datasrc0 datasrcncomp-1
sb.append("{<");
- texture.getImage().getRGB(0, 0, width, height, argb, 0, width);
+ getAsRGB().getRGB(0, 0, width, height, argb, 0, width);
int count = 0;
for (int i = 0; i < argb.length; i++) {
if ((i % width == 0) || (count > 249)) {
@@ -429,6 +433,21 @@ public class PSTilingPattern {
return sb.toString();
}
+ private BufferedImage getAsRGB() {
+ BufferedImage img = texture.getImage();
+ if (img.getType() != BufferedImage.TYPE_INT_RGB) {
+ BufferedImage buf = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
+ Graphics2D g = buf.createGraphics();
+ g.setComposite(AlphaComposite.SrcOver);
+ g.setBackground(Color.white);
+ g.fillRect(0, 0, img.getWidth(), img.getHeight());
+ g.drawImage(img, 0, 0, null);
+ g.dispose();
+ return buf;
+ }
+ return img;
+ }
+
/** {@inheritDoc} */
public int hashCode() {
return
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org