]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
minor color optimization
authorKeiron Liddle <keiron@apache.org>
Tue, 18 Jul 2000 06:04:07 +0000 (06:04 +0000)
committerKeiron Liddle <keiron@apache.org>
Tue, 18 Jul 2000 06:04:07 +0000 (06:04 +0000)
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

src/org/apache/fop/pdf/PDFColor.java

index bcf83385190c2897b72e4cff2b739d19ec16f6ab..66bb33b7526967b64b8cd4e2deaddf5f0cfd96d8 100644 (file)
@@ -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)