[JAVA2D] createCompatibleImage: why is it faster than creating a Buffered image?

2009-06-05 Thread java2d
Hi all, I am trying to create a BufferedImage manually (e.g. via the constructor) and i am using the DirectColorModel and the SinglePixelPackedSampleModel. I am trying to find the optimal models in order to have an image that is rendered fast. When i use the

Re: [JAVA2D] createCompatibleImage: why is it faster than creating a Buffered image?

2009-06-05 Thread Dmitri Trembovetski
Could you please show the code which creates the BufferedImage? Thanks, Dmitri jav...@javadesktop.org wrote: Hi all, I am trying to create a BufferedImage manually (e.g. via the constructor) and i am using the DirectColorModel and the SinglePixelPackedSampleModel. I am trying to

Re: [JAVA2D] createCompatibleImage: why is it faster than creating a Buffered image?

2009-06-05 Thread java2d
Of course. Here is a proc that converts a binary image to a compatible RGB: public static BufferedImage convertToSinglePixelPackedSampleModel_BINARY(BufferedImage image) { int[] bitMasks = new int[]{0x00ff, 0xff00, 0x00ff}; SinglePixelPackedSampleModel sampleModel = new

Re: [JAVA2D] createCompatibleImage: why is it faster than creating a Buffered image?

2009-06-05 Thread java2d
Of course. Here is a proc that converts a binary image to a compatible RGB: [code] public static BufferedImage convertToSinglePixelPackedSampleModel_BINARY(BufferedImage image) { int[] bitMasks = new int[]{0x00ff, 0xff00, 0x00ff}; SinglePixelPackedSampleModel sampleModel =

Re: [JAVA2D] createCompatibleImage: why is it faster than creating a Buffered image?

2009-06-05 Thread Dmitri Trembovetski
The problem with your first method is that you are creating the image with your own DataBuffer. This prohibits this image from ever being cached in video memory since we can not guarantee that the cache will be up to date with the original image. Thus the image is unmanageable. I'm not