Steve,

If you are measuring the size of the image in physical units as displayed on
the screen then that may be contributing to the confusion.
Instead pay attention to the image width & height in pixels.
1 pixel is by default 1/72" when printed.

2D Printing specifies that the Graphics2D (G2D) you get when printing is
at a user space resolution of 72 dpi (ie pixels-per-inch).

So if you draw a 72 pixel horizontal or vertical line it should measure
one inch on the paper - assuming you did not apply any additional scaling
to the G2D.

The transform in the G2D includes the scaling between user space and the actual
printer resolution.

Eg. for a 360 dpi printer, the x & y scale factors would be each be 5.0

So, if you know what size you want your BufferedImage to be on the printed page,
you need to know the hgt & width in pixels and then you can scale either
your image, or the G2D to match.

-phil.

> Date: Sat, 5 Feb 2000 23:12:44 -0800
> From: "Steve <[EMAIL PROTECTED]>" <[EMAIL PROTECTED]>
> Subject: [JAVA2D] Transformation Help
> To: [EMAIL PROTECTED]
>
> If anyone could help to clarify my understanding of how 2D handles
> tranformations from User Space to Device Space, I would be very
> grateful! After having read O'Reilly's Java 2D Graphics and spending
> hours going through this group and searching java.sun.com, I'm
> still not able to correlate the way in which Java 2 (or 2D API) is
> supposed to work with what I'm actually experiencing. My understanding
> is that "the 2D API provides an automatic transformation from User
> Space to Device Space so that the results of rendering are the same
> size, regardless of the output device." (from Java 2D Graphics, pg.273).
> Unfortunately, I'm not experiencing this behaviour. When I print a
> BufferedImage which is 6.72" x 4.6" and I don't do any scaling, I get an
> image on paper that is about 9" x 8.5" (sorry, those numbers may not
> be absolutely accurate, but something like that).
>
> My first attempt to resolve this was to use the getNormalizingTransform
> method from GraphicsConfiguration. This didn't work. I tried this code:
>
> g2.setTransform(gc.getDefaultTransform());
> g2.transform(gc.getNormalizingTransform());
> g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
>
> I believe, I didn't get output when attempting this. (Sorry I can't
> provide more details but I was under a deadline and just had to
> move on... I did however tinker with a few variations of the above,
> all to no avail.). I'm also confused as to why a getNormalizingTransform
> is even necessary if an automatic transform from user space to device
> space is supposed to take place.
>
> I was finally able to achieve the correct translation with the following:
>
> g2.scale(.75f, .75f);
> g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
>
> Unfortunately, I don't completely understand why this is working (or
> necessary). What strikes me as possibly significant is that
> 72 DPI / .75 = 96 (which I believe is the actual screen resolution
> under Windows). Perhaps I'm just not catching on... Again, if anyone
> has any helpful suggestions I would really appreciate it.
>
> P.S. I'm also very interested in the Java 1.1 hi-res printing workaround
> (draw into hi-res off screen buffer then send to printer and let it scale).
> I have this working properly but also perplexed regarding scaling?
> (At the moment I'm only getting output if the printer is set to its
> default resolution (i.e. 300)??)
>
> --Steve
>
> ===========================================================================
> 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