Accelerated (transparent) images once again...

Hi there.
I want to load images and have them hw accelerated. I’ve read many tutorials, the JavaDoc and the forum topics here and think I have done everything correct, but my images are never gets accelerated.
Am I missing something? Below is my code for image loading if anyone could give me a hint:

This one is my the real image loading (my codec files):

            
return ImageIO.read(location);

This one manages the resource for my engine:


        this.image = (BufferedImage) this.codec.decode(this.location);
        ImageCapabilities ic = this.image.getCapabilities(this.image
                .createGraphics().getDeviceConfiguration());
        Core.getLogger().info("Image locat: " + this.location);
        Core.getLogger().info("Image accel: " + ic.isAccelerated());
        Core.getLogger().info("Image volat: " + ic.isTrueVolatile());

        GraphicsConfiguration gc = GraphicsEnvironment
                .getLocalGraphicsEnvironment().getDefaultScreenDevice()
                .getDefaultConfiguration();
        BufferedImage accelImage = gc.createCompatibleImage(this.image
                .getWidth(), this.image.getHeight(), this.image
                .getTransparency());

        Graphics2D g2 = accelImage.createGraphics();
        g2.setComposite(AlphaComposite.Src);
        g2.drawImage(this.image, 0, 0, null);
        g2.dispose();
        ic = accelImage.getCapabilities(accelImage.createGraphics()
                .getDeviceConfiguration());

        Core.getLogger().info("AccelImage locat: " + this.location);
        Core.getLogger().info("AccelImage accel: " + ic.isAccelerated());
        Core.getLogger().info("AccelImage volat: " + ic.isTrueVolatile());

But any of the debug outputs give no acceleration and no volatile on output. :frowning:

If you’re transparency from the image is coming back as more than BITMASK the images won’t get accelerated on most platforms (without setting certain flags).

Try setting the transparency of your created compatible image to BITMASK.

Kev

I’ve tried so.
I also tried Transparency.OPAQUE
as well as setting these system properties:
sun.java2d.opengl
sun.java2d.translaccel
sun.java2d.accthreshold

But nothing has given me an accelerated image.
Not to forget: I’m using WindowsXP

In order for image to get “accelerated” it needs to be copied to an accelerated surface (either
a VolatileImage or screen) several times.

Just create a scratch VolatileImage, and copy your image a couple of times onto
that image prior to checking the isAccelerated() property.

Also, if I recall correctly, there were a couple of bugs in 1.5 such that it’d always report the image
as not being accelerated =( But may be I’m confusing that with recently fixed mustang-specific bugs.

Thanks,
Dmitri
Java2D Team

Hmm. Either there is a bug in the isAccelerated() method as you mentioned, or my images don’t get accelerated. :frowning:
In my short test I load an image with ImageIO and then create a VolatileImage from the default GraphicsConfiguration.
After that I copied the BufferedImage 20 times to the VolatileImage, but the VolatileImage was not accelerated…

[Edit]: But I checked the BufferedImage wich was reported as accelerated. Thanks for your help[/Edit]

Another addition:
I only get an accelerated transparent (translucent) image if I set translaccel to true (as documented).
But withou also specifying ‘sun.java2d.accthreshold=0’ I got no acceleration. Is this the normal behaviour (I use the opengl rendering pipe).
This occurs on jdk 1.5 as well as jdk 1.6-ea.

yes, its a bug (don’t have the ID handy).

VIs with alpha-values could be accerlated, but currently are not :frowning:
I think this will be fixed till mustang release…

lg Clemens