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".

Reply via email to