JDK-6788450 : Printing TIFF file with java5 works better than with java 6
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6u10
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2008-12-23
  • Updated: 2011-02-03
  • Resolved: 2011-02-03
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
I am printing scanned document (articles of scientific publication with a lot of text ans figures) in TIFF format into A4 page (2592,3508 in 595,841 points) with a AffineTransform(). Printing works fine with Java 5 but with Java 6 it is a lost of quality of the printed document (many points are not printed).
i use java.awt.Graphics2D.drawRenderedImage(RenderedImage img, AffineTransform xform) for printing


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
in the main program :

    private DocPrintJob dpj = null;
    DocFlavor flavor;
    PrintRequestAttributeSet attributs;

        flavor = DocFlavor.SERVICE_FORMATTED.PAGEABLE;
        attributs = new HashPrintRequestAttributeSet();
        attributs.add(new Copies(1));
        PrintService service = PrintServiceLookup.lookupDefaultPrintService();
        dpj = service.createPrintJob();


             FileSeekableStream stream = null;
             try {
                 stream = new FileSeekableStream(TIFF file);
             } catch (IOException e) {
                 e.printStackTrace();
                 System.exit(0);
             }

            // Store the input stream in a ParameterBlock to be sent to
            // the operation registry, and eventually to the TIFF
            // decoder.
             ParameterBlock params = new ParameterBlock();
             params.add(stream);

            /* r��cup��ration et mise en forme du Tiff */
//            MemoryCacheSeekableStream stream = new MemoryCacheSeekableStream(conn.getInputStream());
            TIFFDecodeParam decodeParam = new TIFFDecodeParam();
            decodeParam.setDecodePaletteAsShorts(true);

            /* mise en forme de l'��dition */
            Paper papier = new Paper();
            papier.setSize(595.2, 841.8);
            papier.setImageableArea(1.0, 1.0, 594.0, 840.0); // installation des marges

            Book book = new Book();
            PageFormat pageFormat = new PageFormat();
            pageFormat.setPaper(papier);

            ImageDecoder dec = ImageCodec.createImageDecoder("tiff", stream, decodeParam);
            int nbPages = dec.getNumPages();

 
            AffineTransform at = new AffineTransform(595.0/2592.0, 0, 0, 841.0/3508.0, 0, 0);

            for (int i = 0; i < nbPages; ++i) {
                RenderedImage op = dec.decodeAsRenderedImage(i);

                book.append(new Document(op, at, fenetre, impressionPage, langue), pageFormat);
            }

            /* page de "fin" */
            book.append(new Document(null, null, fenetre, impressionPage, langue), pageFormat);

            /* lancement de l'��dition */
            Doc doc = new SimpleDoc(book, flavor, null);
            dpj.print(doc, attributs);


-------------------------------------
In the Document class :

public class Document implements Printable {

    RenderedImage op = null;
    AffineTransform at;
    JFrame fenetre;
    JLabel impressionPage;
    String langue;

    Document(RenderedImage op, AffineTransform at, JFrame fenetre, JLabel jl, String langue) {
        this.op = op;
        this.at = at;
        this.fenetre = fenetre;
        this.impressionPage = jl;
        this.langue = langue;
    }

    public int print(Graphics g,  PageFormat pageFormat, int page) {

        if (this.op == null) {
            return(NO_SUCH_PAGE);
        } else {
            Graphics2D g2d = (Graphics2D) g;
            /* intallation dans l'espace d'impression */
            Double dx = new Double(pageFormat.getImageableX());
            Double dy = new Double(pageFormat.getImageableY());
            g2d.translate(dx.intValue(), dy.intValue());

            g2d.drawRenderedImage(this.op, this.at);

            int pageReelle = page + 1;

            if (this.langue.equals("fr")) {
                impressionPage.setText("Impression de la Page N�� " + pageReelle);
            } else {
                impressionPage.setText("Printing Page number" + pageReelle);
            }
            this.fenetre.repaint();

            return(PAGE_EXISTS);
        }
    }

}

---------- END SOURCE ----------

Release Regression From : 5.0
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
EVALUATION Not gotten any feedback from the submitter so will mark this as duplicate of 6696292. Feel free to reopen if this is still reproducible in 6u10.
03-02-2011

EVALUATION This test applies a transform to the image that looks like it would trigger the same accuracy problems discussed in 6696292. That bug was fixed in 6u10, whereas the user here is using 6u1, at least according to the description. The SR says 6u10 but I don't believe it. The submitter should test under 6u10 or 6u11 and report back the results.
23-12-2008