[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> </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 package (last version
Batik 1.5).</FONT></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </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> </DIV>
<DIV><FONT face=Arial size=2><U>1) First problem :</U></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>When transcoding from a WMF file to SVG, the
viewport size 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 two bytes are not read at the end of the record in
WMFRecordStore for the META_CREATEPENINDIRECT case :</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial
size=2> case
WMFConstants.META_CREATEPENINDIRECT:<BR> \
{</FONT></DIV>
<DIV><FONT size=2><FONT face=Arial>
...</FONT><BR></FONT><FONT size=2><FONT
face=Arial> \
/** PATCH
HGIROD<BR> \
* change from Short to Int</FONT><BR><FONT
face=Arial> \
**/</FONT></FONT></DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT face=Arial
size=2> \
// int height = readshort( is
);<BR> \
</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> </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> </DIV>
<DIV dir=ltr style="MARGIN-RIGHT: 0px"><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2><U>1) Second problem :</U></FONT></DIV>
<DIV> </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> </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 this
parameter).</DIV>
<DIV> </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> </DIV>
<DIV> SVGGraphics2D svgGenerator = new
SVGGraphics2D(doc);<BR> /** PATCH H
GIROD<BR> ** otherwise Ellipses
aren't working (for example) (because of Decimal format
<BR> * modifications ins
SVGGenerator Context)<BR>
*/<BR>
svgGenerator.getGeneratorContext().setPrecision(4);</DIV>
<DIV> </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> </DIV>
<DIV>Hervé Girod</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </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