Hello,

Previously I posted this question to the JAI group. But now I figured out that JAI is 
working fine. The problem with printing itself. Sorry for the cross post.

Here is the problem:

I'm trying to print black-and-white TIFF images (size 2500 x 3200) using 
java.awt.print package. I'm getting "Out Of Memory".
Originally, files are not tiled.
I tried both tiled (using "format" operation) and untiled images. The result is the 
same.
I do use tile cache and cache size is 20M.
I draw images something like this:

Graphics2D g2 = (Graphics2D) g;

g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);

RepaintManager currentManager = RepaintManager.currentManager(myPanel);
currentManager.setDoubleBufferingEnabled(false);
try {
  // FIT TO PAGE
  double scaleX = pageFormat.getImageableWidth() / ((double) img.getWidth());
  double scaleY = pageFormat.getImageableHeight() / ((double) img.getHeight());
  g2.translate(0, 0);
  g2.scale(scaleX, scaleY);

  int minX = img.getMinX();
  int minY = img.getMinY();
  g2.drawRenderedImage(img,
    AffineTransform.getTranslateInstance(-minX, -minY));
} finally {
  // Turn double buffering back on
  currentManager.setDoubleBufferingEnabled(true);
  System.gc(); // Even GC does not release resources
}

I used TileCache Tool.
When my applet draws on the screen, it hits cache approximately in 70%-85% (including 
scaling and rotation operation and changing images).
When my applet tries to print it hits cache approximately 60%.
Tile cache size is 20M. It uses not more than 20% of its size.

JDK: 1.3.1_04
JAI: 1.1.1
Image resolution: 300dpi

PrinterJob produces 70-300KB tasks.
Each task eats about 1M from the heap. This memory could not be returned back even 
through calling the garbage collector. Is that a known bug of AWT? Why it consumes so 
much memory when printing?
Is there a workaround for this problem?

Thanks in advance,
Alexander Glazkov

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