AffineTransform with openGL Pipeline slower than without

Hi Everyone,

i’m fetching bufferedImages from camera and want to scale them to whatever window-size is.
Therefore i use the AffineTransform like this

AffineTransform xform2 = AffineTransform.getScaleInstance((double)getWidth() / myWidth, (double)getHeight() / myHeight);

where myWidth / myHeight hold the original Image width/height.
I draw the images via


g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2.drawImage(image, xform2, null);

this works fine with about 25 fps, but when i switch to fullscreen i only got about 7 fps left.
when i run the application with the openGL pipeline Option

-Dsun.java2d.opengl=True

it slows down to 2 fps in small size.

Any idea highly appreciated.

quietschie

Might be because you use bicubic interpolation. It’s probably not hardware accelerated, but I’m no Java2D expert…

Wow,
removing this line gave me 3 more fps with openGL and more than the camera fetches without using openGL.

Unfortunately the quality is now poor.
So thank you, theagentd, this will work for my first draft.

But i’m still open for other solutions.

quietschie

Bicubic interpolation is really slow. Each pixel requires 44 samples from the image being rendered, so it’s a lot of work. You can try VALUE_INTERPOLATION_BILINEAR, which is something in between nearest-neighbor (pixelized) sampling and bicubic sampling (it uses 22 samples). It won’t look as good as bicubic of course, but it’s usually much better than nothing at all.

And most important it’s hardware accelerated(at least very often).

on windows java2D should default to directX, which is faster than opengl
generally java2d seems to work better with directx

just my impression though

You can’t really say “DirectX is faster than OpenGL” since they are both just specs and the driver is the one that implements them. Java2D seems to use DirectX better than OpenGL, which makes it run faster on it but that does not mean DirectX is overall “faster” than OpenGL.

Yes I meant this.

java2D using direct vs java2d using opengl: directx seems to win
has nothing to do with real opengl

quietschie, if you want something faster, look at Slick or Agile2D.