aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2000-07-18 06:04:07 +0000
committerKeiron Liddle <keiron@apache.org>2000-07-18 06:04:07 +0000
commita35a1e8b0db8c4a2072a5672e3a67c5b559f76a2 (patch)
tree66a3dd36c5778b9e4e66fbeec118224845f87bdf
parentd25b78be5d1fb840c67af7a32e9f15e349ad907a (diff)
downloadxmlgraphics-fop-a35a1e8b0db8c4a2072a5672e3a67c5b559f76a2.tar.gz
xmlgraphics-fop-a35a1e8b0db8c4a2072a5672e3a67c5b559f76a2.zip
minor color optimization
if all color components are the same then use g og G git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193520 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/org/apache/fop/pdf/PDFColor.java31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/org/apache/fop/pdf/PDFColor.java b/src/org/apache/fop/pdf/PDFColor.java
index bcf833851..66bb33b75 100644
--- a/src/org/apache/fop/pdf/PDFColor.java
+++ b/src/org/apache/fop/pdf/PDFColor.java
@@ -223,21 +223,34 @@ public class PDFColor extends PDFPathPaint {
if(this.colorSpace.getColorSpace()==ColorSpace.DEVICE_RGB)
{//colorspace is RGB
-
+ // according to pdfspec 12.1 p.399
+ // if the colors are the same then just use the g or G operator
+ boolean same = false;
+ if(this.red == this.green && this.red == this.blue) {
+ same = true;
+ }
//output RGB
if(fillNotStroke)
{ //fill
- p.append(pdfNumber.doubleOut(this.red)+" "
- +pdfNumber.doubleOut(this.green)+" "
- +pdfNumber.doubleOut(this.blue)+" "
- +" rg \n");
+ if(same) {
+ p.append(pdfNumber.doubleOut(this.red) + " g\n");
+ } else {
+ p.append(pdfNumber.doubleOut(this.red)+" "
+ +pdfNumber.doubleOut(this.green)+" "
+ +pdfNumber.doubleOut(this.blue)+" "
+ +" rg \n");
+ }
}
else
{//stroke/border
- p.append(pdfNumber.doubleOut(this.red)+" "
- +pdfNumber.doubleOut(this.green)+" "
- +pdfNumber.doubleOut(this.blue)+" "
- +" RG \n");
+ if(same) {
+ p.append(pdfNumber.doubleOut(this.red) + " G\n");
+ } else {
+ p.append(pdfNumber.doubleOut(this.red)+" "
+ +pdfNumber.doubleOut(this.green)+" "
+ +pdfNumber.doubleOut(this.blue)+" "
+ +" RG \n");
+ }
}
}//end of output RGB
else if (this.colorSpace.getColorSpace() == ColorSpace.DEVICE_CMYK)