Hi Bhawani,

Bhawani Sharma <[email protected]> wrote on 12/08/2008 10:55:39 PM:

> I am using batik-1.7's WMFTranscoder  to convert wmf images in to gif 
images
[...]
> It's working perfectly for some of the images but not working for all 
the 
> images perfectly.
> Here i have attached the image for which i am facing this problem.
> http://www.nabble.com/file/p20908377/test.wmf test.wmf 

   The problem appears to be in the way the viewport for the SVG
is constructed.  Unfortunately I don't know enough about WMF to
know how to fix this correctly.  The following patch is a start but
I'm fairly certain it's not really right, in particular it appears
the WMF stuff ignores a whole bunch of viewport related commands.

Index: 
sources/org/apache/batik/transcoder/wmf/tosvg/WMFHeaderProperties.java
===================================================================
--- sources/org/apache/batik/transcoder/wmf/tosvg/WMFHeaderProperties.java 
    (revision 718310)
+++ sources/org/apache/batik/transcoder/wmf/tosvg/WMFHeaderProperties.java 
    (working copy)
@@ -588,12 +588,12 @@
         // sets the width, height, etc of the image if the file does not 
have an APM (in this case it is retrieved
         // from the viewport)
         if (! isAldus) {
-            width = vpW;
-            height = vpH;
-            right = vpX;
-            left = vpX + vpW;
-            top = vpY;
-            bottom = vpY + vpH;
+            width  = (int)vpW;
+            height = (int)vpH;
+            right  = (int)vpX;
+            left   = (int)(vpX + vpW);
+            top    = (int)vpY;
+            bottom = (int)(vpY + vpH);
         } 
         resetBounds();
         return true;
Index: 
sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFReader.java
===================================================================
--- sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFReader.java   
 (revision 718310)
+++ sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFReader.java   
 (working copy)
@@ -40,7 +40,7 @@
     public static final float MM_PER_PIXEL = 25.4f / 
Toolkit.getDefaultToolkit().getScreenResolution();
     protected int left, right, top, bottom, width, height, inch;
     protected float scaleX, scaleY, scaleXY;
-    protected int vpW, vpH, vpX, vpY;
+    protected float vpW, vpH, vpX, vpY;
     // the sign values for X and Y, will be modified depending on the 
VIEWPORT values
     protected int xSign = 1;
     protected int ySign = 1;
@@ -389,6 +389,11 @@
             width = right - left;
             height = bottom - top;
 
+            vpX = left;
+            vpY = top;
+            vpW = width;
+            vpH = height;
+
             // read the beginning of the header
             mtType = readShort( is );
             mtHeaderSize = readShort( is ); 
Index: sources/org/apache/batik/transcoder/wmf/tosvg/WMFRecordStore.java
===================================================================
--- sources/org/apache/batik/transcoder/wmf/tosvg/WMFRecordStore.java 
(revision 718310)
+++ sources/org/apache/batik/transcoder/wmf/tosvg/WMFRecordStore.java 
(working copy)
@@ -37,7 +37,6 @@
     private URL url;
 
     protected int numRecords;
-    protected float vpX, vpY;
     protected List records;
 
     private boolean _bext = true;
@@ -266,8 +265,8 @@
                     // sets the width, height of the image if the file 
does not have an APM (in this case it is retrieved
                     // from the viewport)
                     if (! isAldus) {
-                        this.width = vpW;
-                        this.height = vpH;
+                        this.width  = (int)vpW;
+                        this.height = (int)vpH;
                     } 
                 }
                 break;

Reply via email to