[prev in list] [next in list] [prev in thread] [next in thread] 

List:       batik-dev
Subject:    Problems in   "transcoder.wmf.tosvg" package
From:       Hervé_Girod <herve.girod () club-internet ! fr>
Date:       2003-07-31 15:12:55
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hello !

I think I have found two bugs in the "transcoder.wmf.tosvg" package  package (last \
version Batik 1.5).

All my examples can be reproduced with the attached WMF file (generated by PPT, on \
WINDOWS Me).

1) First problem :

When transcoding from a WMF file to SVG, the viewport size is correct but there is \
nothing in it. After checking for the reason of this problem, I found that some of \
the records are not read. In fact, the last record has a false size (very big), \
because two bytes are not read at the end of the record in WMFRecordStore for the \
META_CREATEPENINDIRECT case :

           case WMFConstants.META_CREATEPENINDIRECT:
                {
                    ...
                    /** PATCH HGIROD
                     * change from Short to Int
                     **/
                    // int height = readshort( is );
                    int height = readInt( is );

After changing readShort by readInt, no records are forgotten.

1) Second problem :

There is sometimes a null pointer exception in SVGGeneratorContext (for my example, \
it is when trying to paint the Ellipse), in the doubleString method.

The reason of this problem is that the WMFTranscoder class doesn't set the Precision \
parameter (DecimalFormat) of the context (this problem wasn't there in previous Batik \
versions, because the conversion didn't use this parameter).

It is easy to fix this problem by setting this precision explicitly in the \
WMFTranscoder class after creating the SVGGraphics2D object :

        SVGGraphics2D svgGenerator = new SVGGraphics2D(doc);
        /** PATCH H GIROD
         ** otherwise Ellipses aren't working (for example) (because of Decimal \
                format 
         * modifications ins SVGGenerator Context)
         */
        svgGenerator.getGeneratorContext().setPrecision(4);

But may be a new transcoding hint key could be used in this case (and may be it \
exists, I haven't checked it, although in that case it is not used by the \
WMFTranscoder class).

Hervé Girod


[Attachment #5 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4611.1300" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hello !</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial><FONT size=2>I think I have found two bugs in the 
</FONT><FONT size=2>"transcoder.wmf.tosvg" package&nbsp; package (last version 
Batik 1.5).</FONT></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>All my examples can be reproduced with the attached 
WMF file (generated by PPT, on WINDOWS Me).</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><U>1) First problem :</U></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>When transcoding from a WMF file to SVG, the 
viewport size&nbsp;is correct but there is nothing in it. </FONT><FONT 
face=Arial size=2>After checking for the reason of this problem, I found that 
some of the records are not read. In fact, the last record has a false size 
(very big), because&nbsp;two bytes are not read&nbsp;at the end of the record in 
WMFRecordStore for the META_CREATEPENINDIRECT case :</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 
WMFConstants.META_CREATEPENINDIRECT:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
 {</FONT></DIV>
<DIV><FONT size=2><FONT face=Arial>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
...</FONT><BR></FONT><FONT size=2><FONT 
face=Arial>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
 /** PATCH 
HGIROD<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
                
* change from Short to Int</FONT><BR><FONT 
face=Arial>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
                
**/</FONT></FONT></DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT face=Arial 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
 // int height = readshort( is 
);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
 </FONT><FONT face=Arial size=2>int height = readInt( is );</FONT></DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT face=Arial 
size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT face=Arial size=2>After changing 
readShort by readInt, no records are forgotten.</FONT></DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT face=Arial 
size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2><U>1)&nbsp;Second problem :</U></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>There is sometimes a null pointer exception in SVGGeneratorContext (for my 
example, it is when trying to paint the Ellipse), in the doubleString 
method.</DIV>
<DIV>&nbsp;</DIV>
<DIV>The reason of this problem is that the WMFTranscoder class doesn't set the 
Precision parameter (DecimalFormat) of the context (this problem wasn't there in 
previous Batik versions, because the conversion didn't use&nbsp;this 
parameter).</DIV>
<DIV>&nbsp;</DIV>
<DIV>It is easy to fix this problem by setting this precision explicitly in the 
WMFTranscoder class after creating the SVGGraphics2D object :</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SVGGraphics2D svgGenerator = new 
SVGGraphics2D(doc);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /** PATCH H 
GIROD<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ** otherwise Ellipses 
aren't working (for example) (because of Decimal format 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * modifications ins 
SVGGenerator Context)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
svgGenerator.getGeneratorContext().setPrecision(4);</DIV>
<DIV>&nbsp;</DIV>
<DIV>But may be a new transcoding hint key could be used in this case (and may 
be it exists, I haven't checked it, although in that case it is not used by the 
WMFTranscoder class).</DIV>
<DIV>&nbsp;</DIV>
<DIV>Hervé Girod</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV></FONT></DIV></BODY></HTML>


["test.wmf" (application/octet-stream)]

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic