Java Printing ( DPI )

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

[1384 byte] By [ibalosha] at [2007-11-27 6:48:58]
# 1

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.

ibalosha at 2007-7-12 18:22:30 > top of Java-index,Java Essentials,Java Programming...