Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6788450

Printing TIFF file with java5 works better than with java 6

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 6u10
    • client-libs
    • 2d
    • x86
    • windows_2000

      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.

            jgodinez Jennifer Godinez (Inactive)
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: