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".

Reply via email to