Fop
  1. Fop
  2. FOP-1107

Graphic scaling scale-to-fit Not working as expected

    Details

    • Type: Bug Bug
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: trunk
    • Fix Version/s: None
    • Component/s: images
    • Labels:
      None
    • Environment:
      Operating System: other
      Platform: Other
    • External issue ID:
      37815

      Description

      When scaling an external graphic using

      <fo:external-graphic src="file:../graphics/ltcwidth.jpg" width="100%"
      content-width="scale-to-fit" content-height="100%"/>

      So that graphics that are too wide are scaled down but graphics that fit remain
      unscaled it does not operate as expected.

      Graphics that are too wide are invalidated
      Graphics the should not be scaled are streched to fit the width only.

      1. fop.diff
        0.9 kB
        Tom
      2. after.pdf
        79 kB
        Tom
      3. before.pdf
        79 kB
        Tom
      4. fopbugeg.zip
        96 kB
        Tom

        Activity

        Tom created issue -
        Hide
        Tom added a comment -

        Attachment fopbugeg.zip has been added with description: Input fo file and associated external graphics

        Show
        Tom added a comment - Attachment fopbugeg.zip has been added with description: Input fo file and associated external graphics
        Hide
        Tom added a comment -

        Attachment before.pdf has been added with description: Pdf showing the output

        Show
        Tom added a comment - Attachment before.pdf has been added with description: Pdf showing the output
        Hide
        Tom added a comment -

        Attachment after.pdf has been added with description: Pdf showing how it should be after patch is applied

        Show
        Tom added a comment - Attachment after.pdf has been added with description: Pdf showing how it should be after patch is applied
        Hide
        Tom added a comment -

        The fopbugeg.zip attached file contains an example that shows how it fails this
        example is an edited version of the images.fo example in the source tree. It is
        archived so that the images are in the same relative path as they were originaly.

        The before.pdf attached file shows the output as is generated with the current
        version.

        Show
        Tom added a comment - The fopbugeg.zip attached file contains an example that shows how it fails this example is an edited version of the images.fo example in the source tree. It is archived so that the images are in the same relative path as they were originaly. The before.pdf attached file shows the output as is generated with the current version.
        Hide
        Tom added a comment -

        The issue seems to be caused by a lack of a cast before an integer divide is
        assigned to a double eg.

        double rat1 = cwidth / fobj.getIntrinsicWidth();

        where both cwidth and the returned value are integers.

        Adding a double cast to the cwidth seems to fix the problem eg.

        double rat1 = (double) cwidth / fobj.getIntrinsicWidth();

        The submited patch fixes this problem

        I am no JAVA expert so I don't know if this is specific to the implementation
        of JAVA I am running which is 1.5.0_05-b05

        after.pdf shows the output after the patch is applied which is as I expect it
        to be

        Hope this helps and thanks to the development for all their good work

        Show
        Tom added a comment - The issue seems to be caused by a lack of a cast before an integer divide is assigned to a double eg. double rat1 = cwidth / fobj.getIntrinsicWidth(); where both cwidth and the returned value are integers. Adding a double cast to the cwidth seems to fix the problem eg. double rat1 = (double) cwidth / fobj.getIntrinsicWidth(); The submited patch fixes this problem I am no JAVA expert so I don't know if this is specific to the implementation of JAVA I am running which is 1.5.0_05-b05 after.pdf shows the output after the patch is applied which is as I expect it to be Hope this helps and thanks to the development for all their good work
        Hide
        Tom added a comment -

        Attachment fop.diff has been added with description: [PATCH] fixes the problem

        Show
        Tom added a comment - Attachment fop.diff has been added with description: [PATCH] fixes the problem
        Hide
        Jeremias Maerki added a comment -

        Patch applied. Thanks a lot for the detailed error description and the patch!
        http://svn.apache.org/viewcvs?rev=354757&view=rev

        Show
        Jeremias Maerki added a comment - Patch applied. Thanks a lot for the detailed error description and the patch! http://svn.apache.org/viewcvs?rev=354757&view=rev
        Hide
        Glenn Adams added a comment -

        batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed

        Show
        Glenn Adams added a comment - batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed

          People

          • Assignee:
            fop-dev
            Reporter:
            Tom
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development