I think I've discovered at least one problem that you are running into - we don't have an optimized loop to convert from 1-bit binary images to INT_RGB images. Further, the general code that gets used doesn't take the best advantage of the existing optimized loops that do exist.

We only have a loop to convert from 1-bit to INT_ARGB so if you drawImage directly to an INT_RGB image then it will have to do a slower work-around technique.

To find this out (I thought this had been mentioned a couple of years ago on some forum, but I can't seem to find it with a search), there is a hidden utility in the JDK where you can get the system to print out the supported loops. It was originally designed so that you could just execute:

  % java sun.java2d.loops.GraphicsPrimitiveMgr list

and it would print out all of the built-in rendering loops in the system. Unfortunately we broke this at some point and so now it generates an error that a required native method isn't found. The workaround is still simple - compile and run the following very short program and it will do the same thing:

  public class GPMgr {
    public static void main(String argv[]) {
      java.awt.Toolkit.getDefaultToolkit();
      sun.java2d.loops.GraphicsPrimitiveMgr.main(argv);
    }
  }
  % javac GPMgr.java
  % java GPMgr list

I grepped for "Blit" and "ByteBinary" and discovered that there are only convert (Blit(XX, SrcNoEa, YY)) loops for 1-bit to ARGB. The thing that surprised me, though, was that it took 4 times longer even despite the workarounds. I quickly ran a trace on copying a 1-bit image to INT_RGB and discovered that it ends up using a loop called "OpaqueCopyAnyToIntArgb" which is a Java loop that uses a couple of method calls per pixel. There are faster ways it could do this, even without creating a specific loop for this case, but it will take a bit of elbow grease as the logic in that part of the system is a little obscure...

                        ...jim

===========================================================================
To unsubscribe, send email to lists...@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
lists...@java.sun.com and include in the body of the message "help".

Reply via email to