[EMAIL PROTECTED] wrote:
Hi there,

I've got one question regarding two volatile images that reside in the vram and 
about the combining of these two in the moment when they are displayed on the 
screen.

I have one big volatile image that is my backbuffer for the main graphics I 
want to display. I have an other volatile image in the vram that has to contain 
a circle. only this circle should be opaque while the rest of this volatile 
image should be translucent. Before the main backbuffer is switched to the 
screen I want to lay the circle at a special coordinate on top of the main 
buffer in order to mark a specific area on the graphic. The next time I want to 
display the backbuffer, I would like to place the small circle at different 
coordinates. This means that the last overlaying of the circle should not have 
destroyed the contents of the main backbuffer at the location where it appeared 
the last time.

What I want to do is to replace the former used XOr painting mode that is no 
longer usable under jse 6 update 10.

I don't want to disable the direct 3d pipeline because all the rest of my graphic rendering is running significantly better since I use update 10. The only thing is that I miss XOr painting as it was a massively used paintmode in our software. I overcame many of the other xor paintings in our software with repaints of only the affected areas but in this case this does not work (due to our architecture).
So the main question is: Is it possible to perform such a combining of two 
volatile images without destroying the contents on one of them?

If not, then I don't have to look into that direction any longer.

  So I take it that you can't just repaint the part of the back-buffer where
  the circle was rendered the first time? (see the attached example).

  If not, you could copy the part of the back-buffer
  you're about to obliterate with your circle before you do it
  into another volatile image, and then copy that image back
  when the area needs to be restored.

  Thanks,
    Dmitri



Regards,
Maik
[Message sent by forum member 'kiamur' (kiamur)]

http://forums.java.net/jive/thread.jspa?messageID=319528

===========================================================================
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".
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
import static java.lang.Math.*;

/**
 *
 * @author tdv
 */
public class XorVITest extends JPanel implements MouseMotionListener {
    private  BufferedImage bi;
    private int mx;
    private int my;
    private static final int RADIUS = 100;

    private XorVITest(BufferedImage bi) {
        this.bi = bi;
        addMouseMotionListener(this);
        setPreferredSize(new Dimension(bi.getWidth(), bi.getHeight()));
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2d = (Graphics2D) g.create();

        g2d.drawImage(bi, 0, 0, null);
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                             RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setColor(Color.green);
        g2d.fillOval(mx, my, RADIUS, RADIUS);
    }

    public static void main(String[] args) {
        try {
            System.err.println("Loading..");
            URL url = new 
URL("http://lh3.ggpht.com/_uryd8W9bs_g/SNxxhqn0PeI/AAAAAAAABOk/M1fzvKLpF-o/s800/SANY0530.JPG";);
            final BufferedImage bi = ImageIO.read(url);
            if (bi == null) {
                System.err.println("Error loading image.");
                System.exit(1);
            }
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    JFrame f = new JFrame("XorVITest");
                    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    f.add(new XorVITest(bi));
                    f.pack();
                    f.setVisible(true);
                }
            });
        } catch (IOException ex) {
            System.exit(1);
        }
    }

    @Override
    public void mouseDragged(MouseEvent e) {}

    @Override
    public void mouseMoved(MouseEvent e) {
        int oldX = mx;
        int oldY = my;
        mx = e.getX() - RADIUS/2;
        my = e.getY() - RADIUS/2;
        repaint(min(oldX-RADIUS/2, mx-RADIUS/2), min(oldY-RADIUS/2, 
my-RADIUS/2),
                abs(oldX-mx)+RADIUS*2, abs(oldY-my)+RADIUS*2);
    }
}

===========================================================================
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