> I'm getting "Out Of Memory".
Assuming your TIFF image is representing a binary image then the current
printing implementation is inefficient. If you get OutofMemory errors and
can't increase the memory available to the VM (because you are an applet)
then you will need to print the image as tiles.
> RepaintManager currentManager = RepaintManager.currentManager(myPanel);
> currentManager.setDoubleBufferingEnabled(false);
That has no bearing at all on any drawing you do to a printer graphics.
Its a Swing thing and relevant only if you are doing your image printing by
embedding it in a Swing UI and printing that UI usong Component.printAll
which would be a really strange thing to do.
> PrinterJob produces 70-300KB tasks.
do you mean spool files? That doesn't sound too bad.
> 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?
Whether Java heap memory is returned to the O/S is a function of the VM.
It has nothing to do with AWT/2D and is no more under AWT/2D's control than
it is under yours.
I'm not sure under what - if any - circumstances this happens.
-phil.
>
> Date: Wed, 25 Sep 2002 12:04:32 -0600
> From: Alexander Glazkov <[EMAIL PROTECTED]>
> Subject: [JAVA2D] Printing image from JAI
> To: [EMAIL PROTECTED]
>
> 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".
===========================================================================
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".