Thanks to someone's assistance I have attempted to use TexturePaint along 
with BufferedImage to create an image on a rectangle.

I have managed to add a small graphic to the rectangle, but I am having 
trouble with adding an image to a rectangle.  I guess I just don't fully 
understand what is going on in the code.

This code works:
     BufferedImage bi = new BufferedImage(5,5,
                5,BufferedImage.TYPE_INT_RGB);

                  Graphics2D big = bi.createGraphics();

                    // Render into the BufferedImage graphics to create the 
texture
                    big.setColor(Color.green);
                     big.fillRect(0,0,5,5);
                     big.setColor(Color.red);
     big.fillOval(0,0,5,5);
     
               
     // Create a texture paint from the buffered image; this is the 
rectangle
      TexturePaint tp = new  TexturePaint(bi,this);

     // Add the texture paint to the graphics context.
     g.setPaint(tp);

      // Create and render a rectangle filled with the texture
     g.fill((Shape)(this));


However, when I try to change the code to add an image to the rectangle it 
does not work

     BufferedImage bi = new BufferedImage(5,
                5,BufferedImage.TYPE_INT_RGB);
     Graphics2D big = bi.createGraphics();

     // Render into the BufferedImage graphics to create the texture
          
      big.drawImage(actualImage,5,5,null);
          
               
      // Create a texture paint from the buffered image
      TexturePaint tp = new  TexturePaint(bi,this);         
      // Add the texture paint to the graphics context.
       g.setPaint(tp);

        // Create and render a rectangle filled with the texture
       g.drawImage(bi,10,10,10,10,null);



Any suggestions?
Thanks
 -Justin
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 2D Home Page: http://java.sun.com/products/java-media/2D/

Reply via email to