Rhett Sutphin wrote:
Hi,
I was waiting to see if someone with more experience with Java2D would respond to this, but since no one has, here's what I think.
On Wednesday, February 26, 2003, at 11:57 AM, Eric Kolotyluk wrote:
While reading Lawrence Rodriques' book `Building Imaging Applications with Java Technology,' on page 261 he says "If you need better resolution, you can perform the scale operation on the Graphics context."
I'm not sure what he means by better resolution in this context, but
I am not familiar with the book, but it seems likely to me that he is referring to rendering vector graphics to a raster context. If you apply a scale to the Graphics2D object before drawing on it, everything will get proportionally more pixels in the output. More pixels equals better resolution of sloped lines and curves.
He's referring to a demo app called ImagePrint which takes multiple images and prints them on the same page. He's using g.drawImage(image, x, y, w, h, this) for rendering, so I know he's not dealing with AffineTransform in this code. His book reminds me of a professor I had in university who would always breeze through a math example and say Q.E.D. and I would always mutter "I don't think so."
Anyway, we're not dealing with vector graphics at this point, but thanks for the insight when generating vectors.
To put it another way, the continuous media of the vector graphics objects will be sampled at a higher rate, resulting in a smoother approximation.
it's got me thinking about the difference between transforms like
Graphics2D g; AffineTransform t; BufferedImage b;
a) g.scale(2.0, 2.0); g.drawImage(b, 0, 0, null);
b) t.scale(2.0, 2.0); g.drawImage(b, t, null);
Are (a) and (b) equal in performance and quality (aside from which space operations are happening in)? Sometimes it's more convenient to think in one space or the other, but are there any other reason to use one method over the other (or combinations of the two)? This is particularly important in print() methods where far more rendering is performed, especially with high quality large images on large printers.
I think that the process will be indistinguishable for the specific example you've given. However, when there is more than one object being drawn (be they images or Rectangles, or whatever), it seems to me that (a) would/could outperform (b). This is because the matrix multiplication for the scale transform only has to happen once (when the composite is scaled), instead of once per object (when each object is scaled to fit on a larger canvas). I don't know in what contexts (if any) this would be a noticeable difference. It seems like it could be dependent on the particular Java2D implementation, too.
If there were more than one object, wouldn't the result be the same either way? Good experiment for a timing loop.
I wonder about case
c) g.scale(2.0, 2.0); t.scale(0.5, 0.5); g.drawImage(b, t, null);
where you always have the overhead of the Graphics context matrix transform happening on top of the AffineTranform in these cases. You can often increase performance by collapsing the transform - as is obvious in this case - but as I've found in other cases it's much preferable to use t.scale() and save your sanity.
Thanks again for you insight. You given me something to chew on ;-)
Cheers, Eric
Rhett
-- Rhett Sutphin Research Assistant (Software) Coordinated Laboratory for Computational Genomics and the Center for Macular Degeneration University of Iowa - Iowa City, IA 52242 - USA 4111 MEBRF - email: [EMAIL PROTECTED]
===========================================================================
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".
