Re: Fix for 686843, Error in scaling masked images.
"Igor V. Melichev" <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <[email protected]> |
I'm unclear with both the old and the new code.
1. The right rounding formula is
int round(double v)
{
return (int)(v + 0.5);
}
Why another formula is applied in this case ?
If it is taken for a consistency with the image body,
then the image body looks not well rounded.
2. I believe that coordinates are represented with 'fixed'.
Why cast to 'int' ?
Igor.
----- Original Message -----
From: "Jeong Kim" <[email protected]>
To: <[email protected]>
Sent: Monday, January 12, 2004 2:08 AM
Subject: [gs-code-review] Fix for 686843, Error in scaling masked images.
> This is a reminder for my previous posting on 9 May 2003.
>
> Reviewers,
>
> Thanks to Len Sorensen's analysis, I could find that when scaling factors
> of /ImageMatrix in a image mask are negative values, translation offset
> values for rendering the mask are not appropriate.
>
> As you can see in the following code,
> gximage3.c ( 332): origin.y = (int)floor(mrect.p.y);
>
> origin is the variable for translation of the mask and
> it just takes floor of the mrect.p.y.
>
> As it is the offset value, it must take 'ceil' value in the case of
> negative.
> So I changed the code as follows and it works now!
>
> origin.y = (mrect.p.y < 0) ? (int)ceil(mrect.p.y) : (int)floor(mrect.p.y);
>
>
> Log:
> When scaling factors of /ImageMatrix in a image mask for ImageType3 are
> negative, translation offset values for image mask rendering are
> incorrect and it makes abnormal output (eg. white lines).
> This patch fixes this bug #686843. Thanks to Len Sorensen for the
analysis.
>
> Index: src/gximage3.c
> ===================================================================
> RCS file: /cvs/ghostscript/gs/src/gximage3.c,v
> retrieving revision 1.12
> diff -C2 -r1.12 gximage3.c
> *** src/gximage3.c 18 Aug 2003 21:21:57 -0000 1.12
> --- src/gximage3.c 11 Jan 2004 23:04:39 -0000
> ***************
> *** 329,334 ****
> )
> return code;
> ! origin.x = (int)floor(mrect.p.x);
> ! origin.y = (int)floor(mrect.p.y);
> code = make_mid(&mdev, dev, (int)ceil(mrect.q.x) - origin.x,
> (int)ceil(mrect.q.y) - origin.y, mem);
> --- 329,334 ----
> )
> return code;
> ! origin.x = (mrect.p.x < 0) ? (int)ceil(mrect.p.x) :
> (int)floor(mrect.p.x);
> ! origin.y = (mrect.p.y < 0) ? (int)ceil(mrect.p.y) :
> (int)floor(mrect.p.y);
> code = make_mid(&mdev, dev, (int)ceil(mrect.q.x) - origin.x,
> (int)ceil(mrect.q.y) - origin.y, mem);
>
> _______________________________________________
> gs-code-review mailing list
> [email protected]
> http://www.ghostscript.com/mailman/listinfo/gs-code-review
>