Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Printing hi-res (say, 300 dpi) images  RSS feed

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
dave taubler
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
dave taubler
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!