The chief problem I have with Java printing is that more scaling seems
to be occuring than what I tell it, at least as regards images.  As a
consequence, I am not able to add accurate overlays to my image a print
time.  This means I have to create a combined image and print it which
I'm finding can be difficult and is always much slower and more resouce
intensive.

Briefly, I have a variety of scanned images, mostly 8.5" x 11" TIFF
Group IVs at 200dpi although I've many other formats, sizes, etc., too.
I can read and display these with JAI (or commercial software) just fine
and I can accurately annotate them with Java2D.  In my JPanel, the
images and overlays look as good as they do on a C++ coded application
running on Windows or Macintosh, regardless of if the image is displayed
at 20% or 100% or whatever.  However, the annotations **never** align
properly when I print the image although I apply the same scaling to
both and use the same routines to draw the annotations.  To give one
example, in my print class's setup method, I call

    AffineTransform at;
    double scale;
    ...

    double scaleX = pageFormat.getWidth()/rendered_image.getWidth();
    double scaleY = pageFormat.getHeight()/rendered_image.getHeight();
    scale = Math.min( scaleX, scaleY );
    at = AffineTransform.getScaleInstance( scale, scale );

In the print() method, I call

    g2.drawRenderedImage( rendered_image, at );

and the my routine to print the annotations--just as I do in my JPanel's
paintComponent() class--but the annotations come out larger, as if the
image was reduced by more than the scale amount alone.

I get the same results with a commercial Java image package, calling its
print method on my image and adding my own annotations in the same
manner.

Can anyone tell me what is going on?

On Mon, 2001-10-08 at 18:34, Phil Race wrote:
> Thad,
>
> Printing needs to set up transforms
> 1) to scale to the device
> 2) to rotate to the portrait/landscape/reverse landscape orientations.
>
> Also it sets the origin to the physical corner of the paper which typically
> is not reachable by the printer hardware. So you need to translate to
> imageable X/imageable Y to get the origin of your coordinate space to
> be within the clipped area. Its fairly common practice to make that
> translation the first line of your print(..) method.
>
> So if you add that translate you supply to the scaling and rotation you
> can see there's going to be a fairly complex transform in effect.
>
> But there's no problem/bug I know of in combining this with any
> additional transforms you specify, other than coding ones common to
> dealing with tranforms as Jim mentioned.
>
> -phil.
>
>...
> >
> > ---------- Forwarded Message ----------
> > Date: Monday, October 08, 2001 15:05:02 -0400
> > From: Thad Humphries <[EMAIL PROTECTED]>
> > To: Jim Graham <[EMAIL PROTECTED]>
> > Subject: Re: [JAVA2D] Playing with Transforms
> >
> > This tutorial is most instructive.  A couple of points:
> >
> > 1) Does Java2D use affine transforms for handling landscape printing?
> > If so, how does it combine with translations and other transforms I
> > might request in the print() method.  As you may know from previous
> > messages, I'm having problem with translating images off the printed
> > page when they are landscape.  Could print() be calling an unseen affine
> > transform for landscape that is messing me up?
> > ...
--
------------------------------------------------------------------------
Thad Humphries              "...no religious test shall ever be required
Web Development Manager      as a qualification to any office or public
Phone: 540/675-3015, x225    trust under the United States." -Article VI

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