pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1652516 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color: PDDeviceN.java PDDeviceNAttributes.java PDDeviceNProcess.java PDICCBased.java PDIndexed.java
Date Fri, 16 Jan 2015 20:09:55 GMT
Author: tilman
Date: Fri Jan 16 20:09:55 2015
New Revision: 1652516

URL: http://svn.apache.org/r1652516
Log:
PDFBOX-2576: use StringBuilder in loops

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceNAttributes.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceNProcess.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDIndexed.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java?rev=1652516&r1=1652515&r2=1652516&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java
Fri Jan 16 20:09:55 2015
@@ -495,18 +495,23 @@ public class PDDeviceN extends PDSpecial
     @Override
     public String toString()
     {
-        String str = getName() + "{";
+        StringBuilder sb = new StringBuilder(getName());
+        sb.append('{');
         for (String col : getColorantNames())
         {
-            str += "\"" + col + "\" ";
+            sb.append('\"');
+            sb.append(col);
+            sb.append("\" ");
         }
-        str += alternateColorSpace.getName() + " ";
-        str += tintTransform + " ";
+        sb.append(alternateColorSpace.getName());
+        sb.append(' ');
+        sb.append(tintTransform);
+        sb.append(' ');
         if (attributes != null)
         {
-            str += attributes;
+            sb.append(attributes);
         }
-        str += "}";
-        return str;
+        sb.append('}');
+        return sb.toString();
     }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceNAttributes.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceNAttributes.java?rev=1652516&r1=1652515&r2=1652516&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceNAttributes.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceNAttributes.java
Fri Jan 16 20:09:55 2015
@@ -34,7 +34,7 @@ import java.util.Map;
  */
 public final class PDDeviceNAttributes
 {
-    private COSDictionary dictionary;
+    private final COSDictionary dictionary;
 
     /**
      * Creates a new DeviceN colour space attributes dictionary.
@@ -124,29 +124,36 @@ public final class PDDeviceNAttributes
     @Override
     public String toString()
     {
-        String str = dictionary.getNameAsString(COSName.SUBTYPE) + "{";
+        StringBuilder sb = new StringBuilder(dictionary.getNameAsString(COSName.SUBTYPE));
+        sb.append('{');
         PDDeviceNProcess process = getProcess();
         if (process != null)
         {
-            str += getProcess() + " ";
+            sb.append(getProcess());
+            sb.append(' ');
         }
 
         Map<String, PDSeparation> colorants;
         try
         {
             colorants = getColorants();
-            str += "Colorants{";
+            sb.append("Colorants{");
             for (Map.Entry<String, PDSeparation> col : colorants.entrySet())
             {
-                str += "\"" + col.getKey() + "\": " + col.getValue() + " ";
+                sb.append('\"');
+                sb.append(col.getKey());
+                sb.append("\": ");
+                sb.append(col.getValue());
+                sb.append(' ');
             }
-            str += "}";
+            sb.append('}');
         }
         catch (IOException e)
         {
-            str += "ERROR";
+            sb.append("ERROR");
         }
-        str += "}";
-        return str;
+        sb.append('}');
+        return sb.toString();
     }
+
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceNProcess.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceNProcess.java?rev=1652516&r1=1652515&r2=1652516&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceNProcess.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceNProcess.java
Fri Jan 16 20:09:55 2015
@@ -32,7 +32,7 @@ import java.util.List;
  */
 public class PDDeviceNProcess
 {
-    private COSDictionary dictionary;
+    private final COSDictionary dictionary;
 
     /**
      * Creates a new DeviceN Process Dictionary.
@@ -97,20 +97,23 @@ public class PDDeviceNProcess
     @Override
     public String toString()
     {
-        String str = "Process{";
+        StringBuilder sb = new StringBuilder("Process{");
         try
         {
-            str += getColorSpace();
-            for (String c : getComponents())
+            sb.append(getColorSpace());
+            for (String component : getComponents())
             {
-                str += " \"" + c + "\"";
+                sb.append(" \"");
+                sb.append(component);
+                sb.append('\"');
             }
         }
         catch (IOException e)
         {
-            str += "ERROR";
+            sb.append("ERROR");
         }
-        str += "}";
-        return str;
+        sb.append('}');
+        return sb.toString();
     }
+
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java?rev=1652516&r1=1652515&r2=1652516&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java
Fri Jan 16 20:09:55 2015
@@ -77,12 +77,14 @@ public final class PDICCBased extends PD
 
     /**
      * Creates a new ICC color space using the PDF array.
+     *
      * @param iccArray the ICC stream object
+     * @throws java.io.IOException if there is an error reading the ICC profile.
      */
     public PDICCBased(COSArray iccArray) throws IOException
     {
         array = iccArray;
-        stream = new PDStream((COSStream)iccArray.getObject(1));
+        stream = new PDStream((COSStream) iccArray.getObject(1));
         loadICCProfile();
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDIndexed.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDIndexed.java?rev=1652516&r1=1652515&r2=1652516&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDIndexed.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDIndexed.java
Fri Jan 16 20:09:55 2015
@@ -125,6 +125,10 @@ public final class PDIndexed extends PDS
 
         // convert the base image to RGB
         BufferedImage rgbImage = baseColorSpace.toRGBImage(baseRaster);
+        
+//File f = new File("C:\\Users\\Tilman Hausherr\\Documents\\Java\\PDFBoxPageImageExtraction",
"BaseRaster-" + baseColorSpace.getName() + System.currentTimeMillis() + ".png");
+//System.out.println("BaseRaster file: " + f.getName());
+//ImageIO.write(rgbImage, "png", f);       
         WritableRaster rgbRaster = rgbImage.getRaster();
 
         // build an RGB lookup table from the raster
@@ -134,6 +138,7 @@ public final class PDIndexed extends PDS
         for (int i = 0, n = actualMaxIndex; i <= n; i++)
         {
             rgbColorTable[i] = rgbRaster.getPixel(i, 0, nil);
+//System.out.println(String.format("%d: %02x %02x %02x - %02x %02x %02x", i, rgbColorTable[i][0],
rgbColorTable[i][1], rgbColorTable[i][2], (int) (colorTable[i][0] * 255f), (int) (colorTable[i][1]
* 255f), (int) (colorTable[i][2] * 255f)));
         }
     }
 
@@ -234,6 +239,12 @@ public final class PDIndexed extends PDS
     private void readColorTable() throws IOException
     {
         byte[] lookupData = getLookupData();
+//File f = new File("C:\\Users\\Tilman Hausherr\\Documents\\Java\\PDFBoxPageImageExtraction",
"Lookup-" + baseColorSpace.getName() + System.currentTimeMillis() + ".dat");
+//FileOutputStream fos = new FileOutputStream(f);
+//fos.write(lookupData);
+//fos.close();
+//System.out.println("Lookup file: " + f.getName());
+
         int maxIndex = Math.min(getHival(), 255);
         int numComponents = baseColorSpace.getNumberOfComponents();
 



Mime
View raw message