Hi Chihiro,
The behavior you are seeing with DST_OVER is correct. The DST_OVER rule
specifies that the resulting pixel is the src pixel *outside* of the
dst area. With the BufferedImage of type ARGB, you have an alpha chanel
that gives the distinction of inside and outside of the dst circle
object.  Inside means alpha chanel is non-zero and outside of the
circle the alpha chanel is zero. So the DST_OVER operation produces the
expected result.  With the on-screen compositing, the screen doesn't
have an alpha chanel and is totally opaque. This is equal to a dst with
the alpha chanel being 1.0 everywhere. So the whole dst surface is one
object, even outside of the circle is inside of the dst object. Therefore
no src pixel is outside of the dst object and nothing from src is shown.
The image you get from createImage() has estentially the same format
as the screen format (totally opaque) and would produce the same result
as with the on-screen compositing case.
The only workaround I can think of in your case right now is to swap
the src and dst content and use the SRC_OVER rule, but this may be
impossible in your situation.
Hope this helps.

Thanks.
thanh



>MIME-Version: 1.0
>Content-MD5: MtKZrFb8UjM3s+cTx/Ua1w==
>Date: Thu, 18 Nov 1999 16:56:22 -0800
>From: Chihiro Saito <[EMAIL PROTECTED]>
>Subject: [JAVA2D] Question: DST_OVER and BufferedImage
>To: [EMAIL PROTECTED]
>
>Hello,
>
> A question for 2D experts..... I'm working for a JavaTV project over at cup01,
>and currently writing some test codes for 2D graphics.
>
> There seems to be a problem in doing DST_OVER in jdk 1.2 without using
>BufferedImage.  When we try to do alphablending DST_OVER onscreen or with
>traditional Image class, then a graphics primitive with DST_OVER composite does
>not display at all!  SRC_OVER worked fine in every case.
>
> This is a problem as there is no BufferedImage implementation in our JavaTV 2D
>code. Is there any document/workaround for it?
>
> Below are the three paint methods.  The first one displays the oval, the
others
>do not.  Also modifying Composite.java at
>
> http://java.sun.com/docs/books/tutorial/2d/display/compositing.html
>
> reproduced the bug.
>
> Thank you for any help you can give me,
> regards,
> Chihiro
>
>
> ________________________
>
>  Chihiro Saito
>  [EMAIL PROTECTED]
>  408-517-6847 (x66847)
> ________________________
>
>
>Case 1: Using BufferedImage, works
>
>      public void paint( Graphics g ) {
>
>         Graphics2D g2 = (Graphics2D) g;
>         Dimension d = getSize();
>
>         BufferedImage buffImg = new BufferedImage( d.width, d.height, Buffered
>Image.TYPE_INT_ARGB);
>
>         Graphics2D gbi = buffImg.createGraphics();
>
>         gbi.setColor( java.awt.Color.darkGray );
>         gbi.fillRect( 30, 30, d.width/2, d.height/2);
>         gbi.setComposite(
>               AlphaComposite.getInstance( AlphaComposite.DST_OVER, 0.5f));
>         gbi.setColor( java.awt.Color.pink );
>         gbi.fillOval( 100, 100, d.width/2, d.height/2);
>
>         g2.drawImage(buffImg, null, 0, 0);
>
>      }
>
>
>Case 2: Using Image, the oval does not show up
>
>      public void paint( Graphics g ) {
>
>         Graphics2D g2 = (Graphics2D) g;
>         Dimension d = getSize();
>
>         Image buffImg = createImage(d.width, d.height);
>         Graphics2D gbi = (Graphics2D) buffImg.getGraphics();
>
>         gbi.setColor( java.awt.Color.darkGray );
>         gbi.fillRect( 30, 30, d.width/2, d.height/2);
>         gbi.setComposite(
>               AlphaComposite.getInstance( AlphaComposite.DST_OVER, 0.5f));
>         gbi.setColor( java.awt.Color.pink );
>         gbi.fillOval( 100, 100, d.width/2, d.height/2);
>
>         g2.drawImage(buffImg, 0, 0, this);
>
>      }
>
> Case 3: Painting directly onscreen, the oval does not show up
>
>       public void paint( Graphics g ) {
>
>         Graphics2D g2 = (Graphics2D) g;
>         Dimension d = getSize();
>
>         g2.setColor( java.awt.Color.darkGray );
>         g2.fillRect( 30, 30, d.width/2, d.height/2);
>         g2.setComposite(
>               AlphaComposite.getInstance( AlphaComposite.DST_OVER, 0.5f));
>         g2.setColor( java.awt.Color.pink );
>         g2.fillOval( 100, 100, d.width/2, d.height/2);
>
>      }
>
>
> ________________________
>
>  Chihiro Saito
>  [EMAIL PROTECTED]
>  408-517-6847 (x66847)
> ________________________
>
>===========================================================================
>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