(J2SE 1.4.1 under Windows 2000 Professional)

In an image editing application, I'm obtaining an Image from a scanner
using the JavaTwain package, and creating a BufferedImage from it as
follows:

Image image;
BufferedImage bimage;
float scale;
. . .
// get image from scanner
. . .
BufferedImage bimage = new BufferedImage(
image.getWidth(null),
image.getHeight(null),
BufferedImage.TYPE_BYTE_GRAY);
Graphics2D g2d = bimage.createGraphics();
g2d.drawImage(image, 0, 0, null);

The BufferedImage is passed to a custom component (subclass of JPanel)
which is displayed within a JScrollPane. The image can be scaled which is
done with the following in the custom component's paintComponent():

public synchronized void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.scale(scale, scale);
 . .
g2d.drawImage(bimage, 0, 0, null);

All very obvious. Now, performance when scrolling large images is fine with
TYPE_BYTE_GRAY. It doesn't make any difference whether I tell the scanner
to pass me a colour, grayscale, or black-and-white image. (Presumably it's
a once-only conversion in the BufferedImage constructor).

However, I'd like to work in black-and-white - the images I'm dealing with
are mainly text and are usually clearer that way. If I change the
BufferedImage type to TYPE_BYTE_BINARY, however, scrolling performance
degrades horribly unless no scaling is done. (More precisely, if the scale
field is set to 1.) Obviously a lot of work is being done with each
repaint, but I don't know what. Again, it makes not difference even if I
request a black-and-white image from the scanner.

Any help will be appreciated.

===========================================================================
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".

Reply via email to