I can't seem to find any information online about printing high resolution photos or images from a Java app, and I'm wondering if anyone here as any experience.
In the app I'm working on, printing out 72 dpi images works as expected. Printing out higher res (like 300 dpi) images doesn't--or maybe it does work as expected, but I want to change the behavior . It seems as though Java is still thinking in terms of printing to screen resolution, because when I try to print a 300 dpi image, it will print out the image 4+ times larger than the actual image, with the same "fidelity" as a 72 dpi image. In other words, if an image is 300 dpi, 4 inches x 6 inches, it will print the image as if it was about 16 inches x 24 inches, at 72 dpi.
Obviously, want I want is a photo-quality 4 x 6 image. Anyone know of any way to force Java printing to do that?
Dave Taubler<br />Specializing in <a href="http://taubler.com/articles/" target="_blank" rel="nofollow">Java and Web Development</a>
I have not actually done this, but I read somewhere that you should scale the Graphics Context as displayed below.
Try it and let us know how it worked.
Good Luck, Henry
Joined: May 15, 2001
Hey H Lander,
Thanks for responding. I ultimately tried another (similar) way, basically by using this version of Graphics2D.drawImage:
dx2 and dy2 basically define rectangular bounds that your image must fit into. To do this, you need to know what your target printed size will be, and do a few calculations. My fear was that it would still print out at a crappy, non-photographic-quality resolution, but that doesn't seem to be the case.
So basically you need to transform the image such that when printed the increase in size due to increase in DPI will offset the transform arriving at the original size but with an increased DPI?
Putting this one in my list of tricks.
Joined: May 15, 2001
From what I learned (after finding a few things onlnie as well as talking with image gurus at my company) is that DPI, or resolution in general, is not an inherent "property" in an image at all. All the images knows about--short of any metadata that might be stored somewhere--is how many samples (or roughly speaking, "dots") it contains.
If you don't specify otherwise, it seems that Java will draw your image to the printer at a size where 72 of those samples or dots will fit into the space of one inch. However, if you use one of the aforementioned methods to tell Java what size you want the image to be printed at, it will fit all of the samples/dots into the dimension that you specify; thus, if you specify a smaller image size, you get a higher resolution printout.