Phil,

> Kate,
>
> not everything about how precisely you are doing the text
> printing in this email thread is clear to me.
>
> Are you drawing text on an image graphics, and then printing
> the resulting image? In that case you are not printing text,
> just an image with some screen resolution text bitmaps. I
> would expect drawing the text anti-aliased to be the best
> solution for text quality in that case but
> you'll get more colours used which may not work as well if
> you are drawing the image on the screen at 24-bit depth but
> saving as a 8-bit PNG image because your palette won't be the
> same. Does JAI allow you to save the PNG image as 24-bit?

Okay... our custom JPanel (which is also used for the display of one graph)
has a method called "paintStuff" that is either called by paintComponent or
can be called explicitly.  In this case, we call it explicitly.  First, we
create a BufferedImage in the main applet using "createImage(int width, int
height)".  Then, we use BufferedImage.createGraphics() to get our Graphics2D
context.  Since paintComponent takes a regular Graphics object (and thus so
does paintStuff, which then casts as Graphics2D) we pass it as a Graphics
object to paintStuff.  paintStuff does all the drawing, including text,
data, axes, etc.  Finally, we save the BufferedImage using JAI as a .png.

Is there a way to tell the BufferedImage before we call paintStuff to be a
different resolution?  I'm really not sure where to go from there.  Or I can
look further into specifying for the PNGImageEncoder to save as 24-bit, if
that will help the text any (we do use antialiasing already -- it makes the
text fuzzy in the image, as I guess is to be expected).

>
> You'd probably be better off if you used the same colour
> depth on-screen and
> for the saved image. How does the saved image look on-screen
> if you re-view
> it?
>
> The real way to get the best printed text quality is of
> course to not save it
> in the image at all, but to explictly print it.
>
> in summary the thing that would I would expect to cause
> obvious pixelation of
> the text is that it was rendered at screen resolution into an image or
> a swing back buffer, which amounts to the same thing.
>
> -phil.
>
> > X-Unix-From: [EMAIL PROTECTED]  Thu May  3 06:37:46 2001
> > Date: Thu, 3 May 2001 08:22:37 -0500
> > From: "Wintjen, Kate" <[EMAIL PROTECTED]>
> > Subject: Re: [JAVA2D] Drawn image rendering quality
> > Comments: To: [EMAIL PROTECTED]
> > To: [EMAIL PROTECTED]
> >
> > Hello John,
> >
> > Doesn't make a difference, since our image when we save it
> to a file is
> > redrawn to the size we want (800x600) before it's saved.
> Printing directly
> > using the PrintComponent class will always render the fonts
> just the way we
> > want no matter what size we scale to.  It'd be really great if the
> >
> > You're right, that it's not specifically a JAI problem, but a Java2D
> > problem.  A coworker working on a very similar project has
> found code that
> > will use Java2D methods to create a PostScript file which
> looks very nice.
> > (I had also found one but it couldn't do
> Graphics2D-specific methods.)  If
> > we can find something that will turn PostScript files into
> some type of
> > image file that can be inserted into PowerPoint then that
> will be extremely
> > useful (especially since the software is distributed with
> its source code).
> >
> > I'm afraid there's not much we can do with Java2D and JAI
> alone that will be
> > able to render the fonts in an image the way we want,
> partly because of the
> > limitations on directly drawing an image as we're doing.
> >
> > Thanks for the mention of the Java2D-interest group. :)
> >
> > Kate
> >
> > > -----Original Message-----
> > > From: John Zhang [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, May 02, 2001 7:34 PM
> > > To: [EMAIL PROTECTED]
> > > Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> > > Subject: RE: Drawn image rendering quality
> > >
> > >
> > > Hi Kate-
> > >
> > > Does it make any difference if the [width,height]
> > > are exactly the same as the panel size?
> > >
> > > This is not a JAI problem and probably Java2D-interest
> > > will provide a satisfactory solution.
> > >
> > > Good luck,
> > > John
> > >
> > > ----
> > >
> > > From:         "Wintjen, Kate" <[EMAIL PROTECTED]>
> > > Subject:      Drawn image rendering quality
> > > Content-Type: text/plain; charset="iso-8859-1"
> > >
> > > I'm using the following code to render an image I have drawn
> > > in a custom
> > > panel:
> > >
> > > String filename = "myfile.png";
> > > BufferedImage buff = (BufferedImage)createImage(width, height);
> > > Graphics2D g2d = buff.createGraphics();
> > > panel.paintComponent(g2d);
> > > JAI.create("filestore", buff, filename, "PNG", null);
> > >
> > > This works, but there's something we're trying to fix.
> > > There's some text in
> > > the drawing, and it's not exactly coming out the way we'd
> > > like, although it
> > > is probably coming out as one would or should expect.
> > >
> > > If we turn on anti-aliasing using RenderingHints, it looks
> > > great on the
> > > screen, even after opening the file for viewing.  However,
> > > the text prints
> > > out fuzzy.  If we make sure anti-aliasing is off with
> > > RenderingHints, it
> > > doesn't look as good on the screen, and printing makes the
> > > text very jagged
> > > and pixelated.
> > >
> > > To print, we're using this class (found off the internet):
> > >
> > > public class PrintUtilities implements Printable {
> > >   private Component componentToPrint;
> > >
> > >   public static void printComonent(Component c) { }
> > >   public static void printComponent(Component c, Rectangle r) {
> > >     new PrintUtilities(c).print(r, orientation);
> > >   }
> > >   public void print(Rectangle r) {
> > >     PrinterJob printJob = PrinterJob.getPrinterJob();
> > >     PageFormat pformat = printJob.defaultPage();
> > >     Paper paper = new Paper();
> > >     pformat.setOrientation(PageFormat.PORTRAIT);
> > >     paper.setImageableArea(r.x, r.y, r.width, r.height);
> > >     pformat.setPaper(paper);
> > >     printJob.setPrintable(this, pformat);
> > >     if (printJob.printDialog()) {
> > >       try {
> > >         printJob.print();
> > >       }
> > >       catch (PrinterException e) {
> > >         System.out.println("Error: " + e);
> > >       }
> > >     }
> > >   }
> > >   public int print(Graphics g, PageFormat pageFormat, int
> pageIndex) {
> > >     if (pageIndex > 0) return(NO_SUCH_PAGE);
> > >     else {
> > >       Graphics2D g2d = (Graphics2D)g;
> > >       g2d.translate(pageFormage.getImageableX(),
> > >                     pageFormat.getImageableY());
> > >       disableDoubleBuffering(componentToPrint);
> > >       componentToPrint.paint(g2d);
> > >       enableDoubleBuffering(componentToPrint);
> > >       return(PAGE_EXISTS);
> > >     }
> > >   }
> > >   public static void disableDoubleBuffering(Component c) {
> > >     RepaintManager currentManager =
> RepaintManager.currentManager(c);
> > >     currentManager.setDoubleBufferingEnabled(false);
> > >   }
> > >   public static void enableDoubleBuffering(Component c) {
> > >     RepaintManager currentManager =
> RepaintManager.currentManager(c);
> > >     currentManager.setDoubleBufferingEnabled(true);
> > >   }
> > > }
> > >
> > > Then, in the class we're printing the panel from, we call:
> > >
> > > PrintUtilities.printComponent(panel, rect);
> > >
> > > The quality of the text when printing is absolutely perfect:
> > > it's clear and
> > > smooth with no fuzziness or pixelation, regardless of whether
> > > anti-aliasing
> > > was on or off.  This is exactly what we'd like to achieve
> > > when saving our
> > > images, is that wonderful text quality.
> > >
> > > Is there any way of doing this?  I'm asking here because
> it might be
> > > possible with the JAI package, even though there may be other
> > > solutions.
> > > We've already tried looking at the various objects
> > > PrintUtilities uses in
> > > order to see if there was a way to capture the output (in
> > > bytes I suppose)
> > > being sent to the printer, but so far that's a no-go.
> So, I'm hoping
> > > there's something in the JAI package that will do what we'd
> > > really like.
> > >
> > > Thanks for reading my long-winded post!
> > > Kate Wintjen
> > >
> > > Kate Wintjen
> > > :-) <[EMAIL PROTECTED]>
> > > * 314-232-6086
> > > * S306-4060
> > >
> >
> >
> ==============================================================
> =============
> > 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".

Reply via email to