This really baffles me! I'm working with very large images of Emily Carr paintings - 12,000 x 7,000 pixels, 300 MB in size. When I view them with Windows Picture and Fax Viewer or Adobe PS they look smooth like an oil painting, but when I view them with my Java programs scaled to fit the screen or printer they have a lot of pixel drop-out making them look like pastels. That is, lots of white pixels randomly scattered around the image.

My paint procedure is fairly simple (below). With smaller loaded images there appears to be no such degradation. All loaded files are PNG loaded into a BufferedImage.

Has anyone see this sort of effect before? Does anyone have any ideas on what I may try or investigate to get to the bottom of this?

Cheers, Eric

    public void paint(Graphics _g) {
        Graphics2D g = (Graphics2D)_g;

        // First check width and height changes to avoid recomputing
        // the scale, and repacking the frame. Waste not, want not.

        int gWidth = getWidth();
        int gHeight = getHeight();
        boolean repack = false;

        if (width != gWidth || height != gHeight) {
            scale = scale(image, getWidth(), getHeight());
            if (scale > 1.0)
                scale = 1.0;
            width  = (int)(image.getWidth()  * scale);
            height = (int)(image.getHeight() * scale);
            size = new Dimension(width, height);
            setPreferredSize(size);
            transform = new AffineTransform();
            transform.scale(scale, scale);
            repack = true;
        }

        g.drawImage(image, transform, null);

        if (repack && jFrame != null)
        jFrame.actionPerformed(actionEvent);
    }




Reply via email to