Hi Jerry,

Thank you for your information.

I had avoided the problem converting INT_ARGB to INT_ARGB_PRE.

But I think it is a work-around,
as

1) Converting to INT_ARGB_PRE lose a little bit precision.
2) Converting requires additional memory and computation.
3) It is curious if the client have to convert INT_ARGB image, before
interpolating.

On the other hand if it is done in Java2D library,
conversion may be done in accumulation time.
If image is converted in accumulation time,
it does not have to lose precision,
and it does not require any additional computation.
Additional computation occurs only when converting back to TYPE_INT_ARGB.

It is nice if Java2D interpolates not only INT_ARGB_PRE but also INT_ARGB.

------------------------------------------------------------
Hitoshi Sato, Yamato Software Laboratory, IBM Japan.
e-mail: [EMAIL PROTECTED]

Jerry Evans wrote:

> > This is a baffling problem first reported by Hitoshi Sato of IBM-Japan
> > some 2-3 weeks ago on this mailing list. It seems like there is a
> > problem using bilinear interpolation on a Buffered Image under some
> > special circumstances. The circumstances are  ...
> >
> > 1) The BufferedImage is a TYPE_INT_ARGB
> > 2) A rectangle is filled with a completely transparent color (say white,
> > although it behaves the same with any color)
> > 3) A smaller rectangle is filled over the top of it using a completely
> > opaque color (also white)
> > 4) The  BufferedImage is then scaled by a factor of 2.0 with Bilinear
> > interpolation using an AffineTransformOp.
> > 5) The resulting BufferedImage is then drawn in a JFrame with a white
> > background.
> >
> > The result is a gray border around the form of the smaller rectangle.
> >
> > If the alpha of the outer rectangle is changed to be even 1, the effect
> > goes away. Does any have a clue as to why this should be the behavior??
>
> Generally, when you perform an operation requiring interpolation (such as
> convolution or scaling with interpolated resampling) on an image with an
> alpha channel, you should use a color model with premultiplied alpha.
>
> An example of why this is true is given in the paper "Compositing, Part 1:
> Theory" by Jim Blinn from IEEE Computer Graphics and Applications, September
> 1994 (reprinted in Blinn's book Jim Blinn's Corner: Dirty Pixels).
>
> If you change the BufferedImage type to TYPE_INT_ARGB_PRE in the sample
> program, there will be no gray border.  Without the premultiplication,
> at the border between 255/255/255/0 pixels and 255/255/255/255 pixels in
> the scaled up image, there are pixels which are the result of resampling
> with input from both types of pixels from the unscaled image.  Resampling
> a non-premultiplied image effectively treats the RGB samples as completely
> independent of the alpha samples for interpolation.  The Blinn paper
> illustrates why this doesn't give the desired result.
>
> Jerry
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff JAVA2D-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to