[JAVA2D] Dithering

2006-05-11 Thread Erik Vanherck
Hi, In a certain piece of code we were using Jai to dither a rendering of our chart objects, however this caused some performance issues and we noticed the RenderingHints.KEY_DITHERING so we tried moving the dithering into the rendering of the chart that was already using the graphics2D of a

Re: [JAVA2D] Dithering

2006-05-11 Thread Dmitri Trembovetski
Hi Eric, final BufferedImage buf = new BufferedImage(Math.round(fWidth*scale), Math.round(fHeight*scale), BufferedImage.TYPE_BYTE_BINARY, new Well, here's you problem. You're creating a binary image, with only two possible colors. So the dithering can't be smooth by definition - each

Re: [JAVA2D] Creating Java Images from native code

2006-05-11 Thread Dmitri Trembovetski
Hello, I think you can do something like this: 1. Create a BufferedImage of appropriate type (say, INT_RGB) 2. get the array from the DataBuffer (((DataBufferInt)(BI.getRaster().getDataBuffer())).getData() in case of INT_[A]RGB image type) and pass it to the native code 3. At

Re: [JAVA2D] Creating Java Images from native code

2006-05-11 Thread java2d
Thanks Dimitri, You've confirmed my initial guess at what would make the most sense. I have one minor question... If I were to use TYPE_3BYTE_BGR I assume that the array is padded at the end of each line much like a Windows BITMAP would expect for alignment. The documentation for

Re: [JAVA2D] Creating Java Images from native code

2006-05-11 Thread java2d
I looked at the documentation for SampleModel, DataBuffer, and Raster and didn't find anything that looked like it would give me the scanline stride. It isn't critical as I think I will use INT_BGR anyway. Thanks, Scott [Message sent by forum member 'swpalmer' (swpalmer)]

Re: [JAVA2D] Creating Java Images from native code

2006-05-11 Thread Chris Campbell
Hi Scott, The scanlineStride property isn't defined on the base SampleModel class, but it is on ComponentSampleModel (which is the SM used by TYPE_3BYTE_BGR): http://download.java.net/jdk6/docs/api/java/awt/image/ ComponentSampleModel.html Thanks, Chris On May 11, 2006, at 11:01 AM, [EMAIL

Re: [JAVA2D] Dithering

2006-05-11 Thread Jim Graham
Hi Erik, There are likely 2 different issues that you are dealing with here. First is the issue of dithering during drawing vs. during imaging. We currently do dithering when rendering an image into a lower color resolution destination, but we don't do any dithering at all when we do draw and