Hi Samo, On Thu, Nov 29, 2001 at 11:03:0p +0100, Samo Pitamic wrote: > Hi all! > > I have the following problem: I have a Buffered image, then I want to > transcode it into as small as possible format for > wireless transfer. The most suitable format is PNG and since the > wireless devices usually only support monochrome > images, I want to encode the image in this mode. Therefore I create an > IndexColorModel with two palette entries, black > and white. Then I call a colorConvertOp.filter(srcImg,destImg), where > destImage has the aforementioned monochrome > IndexColorModel. While this works procedure, it is still missing a > piece. The problem is the destImg looks quite bad, the > light parts of the image are totally white, while others are totally > black. What I want is a dithered BW image that would > show some "grayness".
You'd need to use a color model with more than just two colors. There are predefined image formats in BufferedImage class which may suit you: TYPE_BYTE_GRAY - 256 gray values TYPE_BYTE_BINARY - 1, 2 or 4 bit Here is an example on how to use one of the default BufferedImage formats: (suppose srcImg is your source BufferedImage) BufferedImage dstImg = new BufferedImage(srcImg.getWidth(), srcImg.getHeight(), BufferedImage.TYPE_BYTE_GRAY); Graphics g = dstImg.getGraphics(); g.drawImage(srcImg, 0, 0, null); Thank you, Dmitri > > The question is: how do I dither an image? Specifically, how do I dither > the image to two colors? I'm not familiar with > the dithering algorithm, so I was wondering if there is some > BufferedImageOp or RasterOp that can be configured to > pose as dithering operation? Can dithering be expressed as a convolution > or is it a totally another kind of operation? If > yes, can someone point me to an appropriate kernel, if not, does someone > have this operation implemented? I need a > Java algorithm, preferebly something that works hand-in-hand with > BufferedImage concepts. > > Thanks in advance, > > Samo > > =========================================================================== > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff JAVA2D-INTEREST". For general help, send email to > [EMAIL PROTECTED] and include in the body of the message "help". =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".