You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Thierry Kormann <Th...@sophia.inria.fr> on 2000/10/26 20:02:36 UTC

Re: Image

>     Ok, last time Stephane wanted the whole tree.  Just the modified
> stuff is my preference.

It's ok. it depends on the number of changes.

> TK> Another thing is that I am not able to display that document
> TK> correctly (a grey line appears after a transform).
> 
>     Did you incorperate my fix to AffineRed?  It's a slight
> modification (3 lines or so).  

OK done. I have commit your changes to the CVS tree.
I will send you an email when the new archive is ready.

> TK> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN" [...]
> 
>     This works fine for me with the AffineRed fix...

Argh, ok no more grey lines but try to do an aoi in the following document on 
the botton of the image and then PAN to the bottom, some part of the image are 
not displayed ...


By the way, where do you clean your image cache ???
Do we have a memory leak ???

Thierry.



-- 
Thierry Kormann
email: Thierry.Kormann@sophia.inria.fr  http://www.inria.fr/koala/tkormann/
Koala/Dyade/Bull @ INRIA - Sophia Antipolis






Re: Image

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "TK" == Thierry Kormann <Th...@sophia.inria.fr> writes:

TD>  Ok I can reproduce this, I'll try to resolve the issue.

TK> So, I have tried to find that and it's the aoi which seems to be
TK> wrong.  If you put in ConcreteRasterImageNode [...]

TK> it works better :)

The following patch solves the problem 
(so much for trying to fix the aoi myself).

---

diff -rwu xml-batik/sources/org/apache/batik/refimpl/gvt/ConcreteRasterImageNode.java /home/deweese/batik/xml-batik/sources/org/apache/batik/refimpl/gvt/ConcreteRasterImageNode.java
--- xml-batik/sources/org/apache/batik/refimpl/gvt/ConcreteRasterImageNode.javaThu Oct 26 13:46:36 2000
+++ /home/deweese/batik/xml-batik/sources/org/apache/batik/refimpl/gvt/ConcreteRasterImageNode.java     Thu Oct 26 15:56:17 2000
@@ -84,7 +84,9 @@
     }
 
     public void primitivePaint(Graphics2D g2d, GraphicsNodeRenderContext rc) {
-        if (image == null) {
+        if ((image == null)||
+            (bounds.getWidth()  == 0) ||
+            (bounds.getHeight() == 0)) {
             return;
         }
 
@@ -92,8 +94,8 @@
         AffineTransform origAt = g2d.getTransform();
         AffineTransform at     = (AffineTransform)origAt.clone();
         
-        float tx0 = -image.getMinX();
-        float ty0 = -image.getMinY();
+        float tx0 = image.getMinX();
+        float ty0 = image.getMinY();
 
         float sx  = (float)(bounds.getWidth() /image.getWidth());
         float sy  = (float)(bounds.getHeight()/image.getHeight());
@@ -105,17 +107,17 @@
         // the device coord system, including scaling to our bounds.
         at.concatenate(AffineTransform.getTranslateInstance(tx1, ty1));
         at.concatenate(AffineTransform.getScaleInstance    (sx, sy));
-        at.concatenate(AffineTransform.getTranslateInstance(tx0, ty0));
+        at.concatenate(AffineTransform.getTranslateInstance(-tx0, -ty0));
+
+        AffineTransform usr2src = new AffineTransform();
+        usr2src.concatenate(AffineTransform.getTranslateInstance(tx0, ty0));
+        usr2src.concatenate(AffineTransform.getScaleInstance    (1/sx, 1/sy));
+        usr2src.concatenate(AffineTransform.getTranslateInstance(-tx1, -ty1));
 
         Shape aoi = g2d.getClip();
         if(aoi == null) aoi = getBounds();
 
-        // Map it back to our images coord system.
-        Rectangle2D newAOI = aoi.getBounds2D();
-        newAOI = new Rectangle2D.Float((float)(newAOI.getMinX()+tx0-tx1),
-                                       (float)(newAOI.getMinY()+ty0-ty1),
-                                       (float)(newAOI.getWidth()/sx),
-                                       (float)(newAOI.getHeight()/sy));
+        Shape newAOI = usr2src.createTransformedShape(aoi);
 
         rc.setTransform(at);
         rc.setAreaOfInterest(newAOI);

Re: Image

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "TK" == Thierry Kormann <Th...@sophia.inria.fr> writes:

TK> Could send me an email when downloaded.

    Thanks, you can delete this.

TK> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN" [...]
>>  This works fine for me with the AffineRed fix...

TK> Argh, ok no more grey lines but try to do an aoi in the following
TK> document on the botton of the image and then PAN to the bottom,
TK> some part of the image are not displayed ...

    Ok I can reproduce this, I'll try to resolve the issue.

TK> By the way, where do you clean your image cache ???  Do we have a
TK> memory leak ???

    Not in the way you think.  I use SoftReferences in the cache.  So
there is a slight memory "leak" in that urls can build up (with empty
associated SoftReferences), but the Images will get flushed shortly
after the last hard (normal) reference to them is cleared.

    I suppose I could add a very low priority 'cleanup' (long
sleeping) thread, or every N images, traverse the cache looking for
URL's who's images had been flushed (this would handle any risk of
leaking memory).  Is this worth doing?