Bug 37815 - Graphic scaling scale-to-fit Not working as expected
Summary: Graphic scaling scale-to-fit Not working as expected
Status: CLOSED FIXED
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: images (show other bugs)
Version: trunk
Hardware: Other other
: P2 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-07 04:53 UTC by Tom
Modified: 2012-04-01 07:05 UTC (History)
0 users



Attachments
Input fo file and associated external graphics (95.68 KB, application/octet-stream)
2005-12-07 04:58 UTC, Tom
Details
Pdf showing the output (78.79 KB, application/octet-stream)
2005-12-07 05:00 UTC, Tom
Details
Pdf showing how it should be after patch is applied (78.80 KB, application/octet-stream)
2005-12-07 05:01 UTC, Tom
Details
[PATCH] fixes the problem (923 bytes, patch)
2005-12-07 05:15 UTC, Tom
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom 2005-12-07 04:53:10 UTC
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.
Comment 1 Tom 2005-12-07 04:58:45 UTC
Created attachment 17163 [details]
Input fo file and associated external graphics
Comment 2 Tom 2005-12-07 05:00:06 UTC
Created attachment 17164 [details]
Pdf showing the output
Comment 3 Tom 2005-12-07 05:01:27 UTC
Created attachment 17165 [details]
Pdf showing how it should be after patch is applied
Comment 4 Tom 2005-12-07 05:05:38 UTC
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.
Comment 5 Tom 2005-12-07 05:15:17 UTC
Created attachment 17166 [details]
[PATCH] fixes the problem

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
Comment 6 Jeremias Maerki 2005-12-07 10:43:20 UTC
Patch applied. Thanks a lot for the detailed error description and the patch!
http://svn.apache.org/viewcvs?rev=354757&view=rev
Comment 7 Glenn Adams 2012-04-01 07:05:25 UTC
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed