简体   繁体   中英

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

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM