开发者

Java paint speed relative to color model

I have a BufferedImage with an IndexColorModel. I need to paint that image onto the screen, but I've noticed that this is slow when using an IndexColorModel. However, if I run the BufferedImage through an identity affine transform it creates an image with a DirectColorModel and the painting is significantly faster. Here's the code I'm using

AffineTransformOp identityOp = new AffineTransformOp(new AffineT开发者_开发知识库ransform(), AffineTransformOp.TYPE_BILINEAR);
displayImage = identityOp.filter(displayImage, null);

I have three questions

1. Why is painting the slower on an IndexColorModel?

2. Is there any way to speed up the painting of an IndexColorModel?

3. If the answer to 2. is no, is this the most efficient way to convert from an IndexColorModel to a DirectColorModel? I've noticed that this conversion is dependent on the size of the image, and I'd like to remove that dependency.

Thanks for the help


This is too long for a comment...

Are you sure that the BufferedImage you're creating are the best depending on the OS you're on? You should always create a "compatible" BufferedImage. The fastest on, say, Windows, may be TYPE_INT_ARGB but this is not true on OS X and vice-versa.

Something like this (ouch, the Law of Demeter hurts ;) :

GraphicsEnvironment
        .getLocalGraphicsEnvironment()
        .getDefaultScreenDevice()
        .getDefaultConfiguration()
        .createCompatibleImage(width, height,Transparency.TRANSLUCENT)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜