I have two types of multi IFD TIFF files. One with G4 compressed image
data
and another one is TIFF wrapped JPEGs. G4 images are b&W, 200dpi ,
around 1600x750 pixels. JPEG images are 256gray, 100dpi, 800x300 pixels.

I have no problem reading, displaying or printing. Reading and
displaying
is fast enough, however printing is unacceptably slow. Some times from
my testing (from the moment I click 'OK' in the print dialog to the time

print dialog goes away). All times in seconds.

          HP LaserJet 2100TH    HP LaserJet 2100TN    Epson 700 Photo
                      PCL                                   PS
            600 dpi     1200dpi         300 dpi    600 dpi       360 dpi
720 dpi

JPEG      35             140                8(*)
28                18         58
G4          195
40                                  75

(*) unacceptable print quality

My machine PII-400, 256MB, NT-4.0 workstation.


What can I do speed up printing ?


Thanx

Olek

PS. sending to both JAI and JAVA2D


Here is relevant code from my test program. All error checking striped.

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

public class myui extends javax.swing.JFrame {
    private File               inputFile = null;
    private FileSeekableStream tiffFile = null;
    private FileSeekableStream jpegFile = null;
    private TIFFDirectory      tiffDir = null;
    private int                nIFD = -1;
    private int                currentIFD = -1;

    private DisplayJAI         display = null;
    RenderedImage              tiffImage = null;
    RenderedImage              printImage = null;
    float                      resolution = -1.0f;

    private void displayTIFF(int ifd) {

 ImageDecoder       decoder = null;

 int compression = -1;
 long stripOffsets = -1;

 tiffFile = new FileSeekableStream(inputFile);
 tiffDir = new TIFFDirectory(tiffFile, ifd);

 TIFFField [] tiffFields = tiffDir.getFields();

 int nFields = tiffDir.getNumEntries();

 for (int i = 0; i < nFields; i++) {
     if (tiffFields[i].getTag() == 259) {
  compression = tiffFields[i].getAsInt(0);
     }
     if (tiffFields[i].getTag() == 273) {
  stripOffsets = tiffFields[i].getAsLong(0);
     }
 }

 if (compression == 4) {
     decoder = ImageCodec.createImageDecoder("tiff", inputFile, null);
     tiffImage = decoder.decodeAsRenderedImage(ifd);
     tiffFile.close();
     // Can't use resolution tag, cause it has a bogus value.
     resolution = 200.0f;
 }

 if (compression == 6)  {
     jpegFile = new FileSeekableStream(inputFile);
     jpegFile.seek(stripOffsets);
     decoder = ImageCodec.createImageDecoder("jpeg", jpegFile, null);
     tiffImage = decoder.decodeAsRenderedImage();
     jpegFile.close();
     resolution = 100.0f;
 }

 RenderedOp ren0 = JAI.create("scale", tiffImage, 72.0f / resolution,
72.0f / resolution, 1.0f, 1.0f, null);
 //
 // Without "format" printing G4 image will get an
InvalidArgumentException
 //
 RenderedOp ren1 = JAI.create("format", tiffImage,
DataBuffer.TYPE_BYTE);

 printImage = (RenderedImage)ren1.getRendering();

 display.set((RenderedImage)ren0.getRendering());

 scrollPane.getViewport().add(display);

    }

    private void Print(java.awt.event.ActionEvent evt) {
 PrinterJob pj = PrinterJob.getPrinterJob();
 pj.setPrintable( new testprint(printImage, resolution));
 if (pj.printDialog()) {
     pj.print();
 }
    }

}


class testprint implements Printable {

    private RenderedImage image;
    private float         resolution;
    private static AffineTransform at = null;

    public testprint(RenderedImage i, float r) {
 image = i;
 resolution = r;
 at = null;
    }

    public int print(Graphics g, PageFormat pf, int pageIndex) {
 if (pageIndex != 0)
     return NO_SUCH_PAGE;


 Graphics2D g2 = (Graphics2D)g;

 if (at == null) {
     at = AffineTransform.getTranslateInstance(pf.getImageableX(),
pf.getImageableY());
     at.scale(36.0f / resolution, 36.0f / resolution);
 }

 System.out.println(image.getData().toString());
 g2.drawRenderedImage(image, at);


 return PAGE_EXISTS;
    }
}

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

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