Archive for February, 2008

drawImage performance on Leopard

Wednesday, February 27th, 2008

A not very fast but handy way to downscale images in a WebObjects application is using Java 2D APIs, with code like this:


BufferedImage reducedImage = new BufferedImage(newX, newY, BufferedImage.TYPE_INT_RGB);
Graphics2D g = reducedImage.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);

g.drawImage(originalImage, 0, 0, newX, newY, 0, 0, originalImage.getWidth(), originalImage.getHeight(), null);
g.dispose();

Although not blazing fast, this is enough for many applications. I could reduce a 7 Mega-Pixels image to something like 250 pixels wide in about one second, or less, in my PowerBook G4. But this was in Tiger.

In Leopard, as some of you may have noticed (and if you have applications deployed on Leopard Server, be aware) this is incredibly slow. When I say slow, I say five minutes, or even more, with the CPU being used at 100% during that time.

There are two reasons that lead to this. The first (which is not a problem in itself, but it’s a cause of the problem): Apple switched from Quartz to Sun2D graphics engine as the default one for Java applications on Leopard. So, all your image manipulation is being done using the Sun pipeline now. This would not be a problem, except for the second reason: the Apple JVM implementation has a bug that is slowing Sun’s pipeline drawImage method to a crawl. Actually, that was not the real reason. I testes this on FreeBSD (using Diablo JDK) and the speed was similar to Leopard’s. Sun2D is REALLY slow, to the point of being useless. I’m now using ImageMagick.

The only solution for now is forcing the application to use Quartz engine. You can do that using the command line option -Dapple.awt.graphics.UseQuartz=true. And, of course, file a bug on this!

I hate IE

Friday, February 1st, 2008

I really don’t undersand. MS has some talented people working for them. After all they make operating systems, office suites, and many more products. They can’t be that dumb. There must be people there that know what they are doing.

So, why is IE such a big pile of crap? If is it so ridiculously flawed? Why they seem to don’t give a shit? What’s the frickin’ problem about showing a layer with z-index = 5 BEYOND a layer with z-index = 60? WHY DOES THE DAMN BACKGROUND LAYER COVES THE FRONT ONE!? Damn it. Fix IE once for all. Or cancel it’s development. Or adopt Gecko or WebKit or whatever the hell they want. But stop wasting my time. I’m so pissed off with childish and pathetic bugs on IE. Where the hell did the IE team learn to code? Oh wait… did they actually learn to code?!