Hello,

  yes, 17 seconds seems to be very excessive.

  Here is a couple of suggestions:
  1. instead of using raster when when creating a copy of your image,
     just do a drawImage into a new BufferedImage:
     shapeImageCopy =
       graphicsConfig.createCompatibleImage(
         shapeImage.getWidth(), shapeImage.getHeight(),
         shapeImage.getTransparency());
     Graphics2D g2d = (Graphics2D)shapeImageCopy.getGraphics();
     g2d.setComposite(AlplaComposite.Src);
     g2d.drawImage(shapeImage, 0, 0, null);

     (note that if you're going to scale these images anyway,
     it could be better to create scaled copy in the first
     place, instead of scaling it on every drawImage)

     This will ensure that there is a possibility of caching
     this image in Vram (depending on the pipeline used),
     while your current method prevented that.

  2. Instead of copying your images to the screen as you're
     apparently doing, copy them to an offscreen image,
     (either a BufferedImage (opaque), or a VolatileImage, or
     BufferStrategy) and then copy that image to the screen.
     (use the double buffering technique).
     When you render to the screen, in order to do the compositing
     with the destination pixels we have to read them back from vram,
     which is an expensive operation.

     Depending on your choice of the pipeline and whether your images
     are translucent or not, you may chose different types of
     back-buffers.

     The default pipelines do not accelerate alpha compositing
     (and transforms), so your best choice would be a BufferedImage
     for a back-buffer.

     For OpenGL or D3D pipelines, BufferStrategy or VolatileImages
     would be better.

  3. try using one of the non-default pipelines in jdk6
   OpenGL (-Dsun.java2d.opengl=True), or Direct3D (-Dsun.java2d.d3d=True)

  4. Probably the simplest way - disable the use of DirectDraw by
   setting -Dsun.java2d.noddraw=true . This will probably help
   even without changing your application, but I still suggest
   following the advices above.

  Thank you,
    Dmitri
  Java2D Team

On Thu, Feb 22, 2007 at 08:33:46AM -0800, [EMAIL PROTECTED] wrote:
 > I've written an application that loads an image and draws a repeated grid of 
 > this image to the screen like a chessboard.  When I use a jpeg or a png 
 > (with no transparency) I can draw 1000 of these instantaneously (or at least 
 > fast enough for my purposes).  When I use a transparent image (for example I 
 > am testing with a coloured ball on a white background and then the same ball 
 > but with 'no' background), it takes approximately 17 seconds to draw the 
 > final image (of 1000 balls).  This is a program that I was working on some 
 > time ago and as I remember it, it worked fine.  Since I last used it I have 
 > reinstalled my OS and put on a newer version of NetBeans (and JDK).  Is this 
 > a known problem or is there something else going on here?
 >
 > I am running Windows XP.  The image I was testing with is 185 x 185 pixels 
 > (so not big).
 >
 > I essentially load the file and create a copy (as it is used elsewhere),
 >
 > // Create an exact copy of the buffered image
 >         WritableRaster raster = shapeImage.copyData( null );
 >         BufferedImage shapeImageCopy = new BufferedImage( 
 > shapeImage.getColorModel(), raster, shapeImage.isAlphaPremultiplied(), null 
 > );
 >
 >
 > then I do an affine transform to get it the right size and then...
 >
 >         // Draw the image onto the canvas
 >         g.drawRenderedImage(shapeImage, affine_scale);
 >
 > The problem is purely with transparent png's but I need to use these!  As I 
 > said, for jpeg and non-transparent pngs everything is absolutely fine.
 > [Message sent by forum member 'olly_olly' (olly_olly)]
 >
 > http://forums.java.net/jive/thread.jspa?messageID=204839
 >
 > ===========================================================================
 > 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