Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-888

Bug in SVGFeOffsetElementBridge when using primitiveUnits="objectBoundingBox" -- Wrong Translation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Resolution: Unresolved
    • 1.8
    • None
    • GVT Filters
    • None
    • Operating System: Windows Vista
      Platform: PC

    Description

      Hello,

      Line 106 of SVGFeOffsetElementBridge states:

      float dx = convertNumber(filterElement, SVG_DX_ATTRIBUTE, 0, ctx);
      float dy = convertNumber(filterElement, SVG_DY_ATTRIBUTE, 0, ctx);
      > AffineTransform at = AffineTransform.getTranslateInstance(dx, dy);

      However, this sets an offset filter in userSpace coordinates, not in objectBoundingBox units.

      The translation should take into account the object bounding box (as required by spec http://www.w3.org/TR/SVG/filters.html#feOffsetElement),
      which is available in
      filteredElement.geometryBounds
      in this method.

      I suggest in case of objectBoundingBox units to rather set:

      > AffineTransform at = AffineTransform.getTranslateInstance(
      dx * filteredElement.geometryBounds.getWidth() ,
      dy * filteredElement.geometryBounds.getHeight() );

      Being new to Batik, I don't master all the implications, so decide what's best!

      Congrats for Batik, this great piece of work!

      -----------------------------------------

      Test case:

      Apply the following filter to any <svg>

      <defs>
      <filter id="CenteringFilter" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox" x="-0.5" y="-0.5" width="1.5" height="1.5">
      <feOffset in="SourceGraphic" dx="0.5" dy="-0.5" /> <!- FIXME dx & dy !!! -->
      </filter>
      </defs>

      -----------------------------------------

      Note: this works fine with Adove Viewer but not with Batik.

      Attachments

        Activity

          People

            batik-dev@xmlgraphics.apache.org Batik Developer's Mailing list
            amram@free.fr Eric Amram
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: