• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Printing and DPI

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am writting an application in java which needs to print graphics in different printer resolutions (300,600dpi...).

When I add image that needs to be printed, it's all good by default, image is printed in correct size, for example 1x1 inch (image size is set to 72x72 in user space (drawImage(...)).

AffineTransform is:

[8.333333333333334, 0.0, -75.0], [0.0, 8.333333333333334, -42.0]

that is 600dpi ?

When I change resolution to 300 dpi (new PrinterResolution(300,300...)) image is twice smaller !! ?

AffineTransform is:

[4.16, 0.0, -75.0], [0.0, 4.16, -42.0]

and so on...

on 72 dpi image is 8.33 times smaller.

How can I have the same size of printed images, on different printer resolutions ? Shouldn't the size be always the same in the device space (by conversion from user space to device space )?


Also how can I detect dpi resolutions that are available for a printer (max resolution at least)? I tried this:

AttributeSet attrs = new HashAttributeSet();
attrs.add(new PrinterResolution(300,300,PrinterResolution.DPI));

PrintService[] services = PrintServiceLookup.lookupPrintServices(null, attrs);
for (int j=0;j<services.length;j++)
System.out.println("selected printer: " + services[j]);

but I didn't get my printer which supports 300dpi...>
 
Igor Balos
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
also, it's interesting that setting resolution from code and from print dialog doesn't give same result:

from code:

image size, is set to 72x72 (1inch by 1inch) (drawImage(img, posX,posY,72,72,...))

PrinterResolution(300,300,PrinterResolution.DPI))
image printed out is 1/2 x 1/2 inch

PrinterResolution(600,600,PrinterResolution.DPI))
image printed out is 1 x 1 inch

PrinterResolution(1200,1200,PrinterResolution.DPI))
image printed out is 2 x 2 inch

from dialog:

300dpi
image printed out is 1 x 1 inch

600dpi
image printed out is 1 x 1 inch

1200dpi
image printed out is 1/2 x 1/2 inch

What am I missing ? Only thing that I need is that image is printed in the same size for various printer resolutions and for various printers.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic