Millimeters to Pixels to Buffered Image then print it. Does not have the original size

1.2k views Asked by At

So basically my problem is that I basicly create some objects which are filled in as millimeters then converted to pixels using (MM * DPI) / MMPI. This is stored in a buffered Image which I then print, the only problem is, that the image is not the right size according to the millimeters in size I filled in. Is there any correct way to calculate or get the dpi of an buffered image?

Anyhow if someone could show me an example of insterting values in mm then converted to pixels to be used in a buffered image, which could be printed to be the exact size needed.

1

There are 1 answers

1
Selvaraj On

From How to get the dpi of an image(Java)

You can use Apache Commons Sanselan library to get image info: http://commons.apache.org/imaging/index.html.

final ImageInfo imageInfo = Sanselan.getImageInfo(file_);

final int physicalWidthDpi = imageInfo.getPhysicalWidthDpi();
final int physicalHeightDpi = imageInfo.getPhysicalHeightDpi();

DPI is basically for inches, so convert it for ur dest like mm .