Author: tilman
Date: Tue Mar  4 19:34:50 2014
New Revision: 1574180

URL: http://svn.apache.org/r1574180
Log:
PDFBOX-52: use JPXFilter instead of DCTFilter

Modified:
    
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/FilterManager.java
    
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java

Modified: 
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/FilterManager.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/FilterManager.java?rev=1574180&r1=1574179&r2=1574180&view=diff
==============================================================================
--- 
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/FilterManager.java
 (original)
+++ 
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/FilterManager.java
 Tue Mar  4 19:34:50 2014
@@ -32,7 +32,7 @@ import org.apache.pdfbox.cos.COSName;
  */
 public class FilterManager
 {
-    private Map<COSName, Filter> filters = new HashMap<COSName, Filter>();
+    private final Map<COSName, Filter> filters = new HashMap<COSName, 
Filter>();
 
     /**
      * Constructor.
@@ -40,7 +40,6 @@ public class FilterManager
     public FilterManager()
     {
         Filter flateFilter = new FlateFilter();
-        Filter dctFilter = new DCTFilter();
         Filter ccittFaxFilter = new CCITTFaxDecodeFilter();
         Filter lzwFilter = new LZWFilter();
         Filter asciiHexFilter = new ASCIIHexFilter();
@@ -52,8 +51,8 @@ public class FilterManager
         
         addFilter( COSName.FLATE_DECODE, flateFilter );
         addFilter( COSName.FLATE_DECODE_ABBREVIATION, flateFilter );
-        addFilter( COSName.DCT_DECODE, dctFilter );
-        addFilter( COSName.DCT_DECODE_ABBREVIATION, dctFilter );
+        addFilter( COSName.DCT_DECODE, jpxFilter);
+        addFilter( COSName.DCT_DECODE_ABBREVIATION, jpxFilter);
         addFilter( COSName.CCITTFAX_DECODE, ccittFaxFilter );
         addFilter( COSName.CCITTFAX_DECODE_ABBREVIATION, ccittFaxFilter );
         addFilter( COSName.LZW_DECODE, lzwFilter );
@@ -66,8 +65,7 @@ public class FilterManager
         addFilter( COSName.RUN_LENGTH_DECODE_ABBREVIATION, runLengthFilter );
         addFilter( COSName.CRYPT, cryptFilter );
         addFilter( COSName.JPX_DECODE, jpxFilter );
-        addFilter( COSName.JBIG2_DECODE, jbig2Filter );
-        
+        addFilter( COSName.JBIG2_DECODE, jbig2Filter );        
     }
 
     /**

Modified: 
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java?rev=1574180&r1=1574179&r2=1574180&view=diff
==============================================================================
--- 
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java
 (original)
+++ 
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/JPXFilter.java
 Tue Mar  4 19:34:50 2014
@@ -69,7 +69,26 @@ public class JPXFilter implements Filter
                 options.setInt(COSName.BITS_PER_COMPONENT, 
colorModel.getPixelSize() / colorModel.getNumComponents());
                 options.setInt(COSName.HEIGHT, bi.getHeight());
                 options.setInt(COSName.WIDTH, bi.getWidth());
-                result.write(((DataBufferByte) dBuf).getData());
+                
+                if (bi.getType() == BufferedImage.TYPE_3BYTE_BGR)
+                {
+                    // PDFBOX-52
+                    byte[] byteBuffer = ((DataBufferByte) dBuf).getData();
+                    for (int i = 0; i < byteBuffer.length; i += 3)
+                    {
+                        //BGR
+                        //to
+                        //RGB
+                        byte tmp0 = byteBuffer[i];
+                        byteBuffer[i] = byteBuffer[i + 2];
+                        byteBuffer[i + 2] = tmp0;
+                    }
+                    result.write(byteBuffer);
+                }
+                else
+                {
+                    result.write(((DataBufferByte) dBuf).getData());
+                }
             }
             else
             {


Reply via email to