[OpenJDK 2D-Dev] Review Request for JDK-8139183 : drawImage misses background's alpha channel

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Wed Mar 2 14:46:09 UTC 2016


Hi, Jay.
The fix looks fine. Probably we can improve the fix a little bit.

It seems that makeBufferedImage() is used only in two places in 
DrawImage.java. And after the fix in both cases we have:

int type = ((srcData.getTransparency() == Transparency.OPAQUE)
                 ? BufferedImage.TYPE_INT_RGB
                 : BufferedImage.TYPE_INT_ARGB);
img = makeBufferedImage(img, null, type, sx1, sy1, sx2, sy2);

Probably makeBufferedImage can be made private and the logic for type 
selection can be moved to the makeBufferedImage()? the "type" parameter 
can be changed to "opaque" or something like that. In this we can move 
the description why we use ARGB instead of ARGB_PRE to the spec of 
makeBufferedImage().

Can we check VolatileImage in the test as well? and probably some other 
image types(argb_pre, etc)?

On 02.03.16 16:17, Jayathirth D V wrote:
> Hi,
>
> I have updated the changes to select proper Buffer Image type based on
> source transparency and not just using ARGB directly.
>
> Please find the updated webrev for review:
>
> http://cr.openjdk.java.net/~jdv/8139183/webrev.01/
>
> Thanks,
>
> Jay
>
> *From:* Jayathirth D V
> *Sent:* Wednesday, March 02, 2016 5:02 PM
> *To:* 2d-dev at openjdk.java.net; Philip Race; Prasanta Sadhukhan
> *Subject:* Review Request for JDK-8139183 : drawImage misses
> background's alpha channel
>
> Hi,
>
> _Please review the following fix in JDK9:_
>
> __
>
> Bug : https://bugs.openjdk.java.net/browse/JDK-8139183
>
> Webrev : http://cr.openjdk.java.net/~jdv/8139183/webrev.00/
>
> Issue : When we scale any buffered image using drawImage() API which
> takes scale coordinates we are losing alpha channel in background color.
>
> Root cause : We are creating opaque temporary image when we have
> background color and scale is happening in renderImageXform() API of
> DrawImage.java. By making it opaque we are losing translucency.
>
> Solution : Instead of creating opaque RGB temporary image use ARGB
> temporary image to maintain translucency of image.
>
> Thanks,
>
> Jay
>


-- 
Best regards, Sergey.



More information about the 2d-dev mailing list