-
April 14th, 2014, 03:50 AM
#1
How to print images correctly
Hi ALL,
I'm trying to print (to the printer) a small image 265x35 px and it is printed in very poor quality with jagged edges.
When I'm printing it from any other program (e.g. Word, mspaint, etc) it is printed clearly.
Also, the image is printed bigger than it's normal size (approximately 25%). But, I'm not doing any scale in my code.
I did scaled it down to the right size, but the quality still remained very poor and jadged.
The image is a transparent PNG file. I tried with a BMP too, but I got the same results.
I'm using
Code:
Graphics g;
g.drawImage(headerLogo, x, y, headerLogo.getWidth(), headerLogo.getHeight(), imageObserver);
What may be wrong ?
-
April 15th, 2014, 04:32 PM
#2
Re: How to print images correctly
OK, this is getting seriously annoying...
I'm struggling to print an image in its original size and quality.
I tried this time to design my logo (png image) with 150ppi resolution (instead of 72ppi before). I printed it from mspaint and Photoshop and prints crystal clear and in right dimensions.
I printed from Java (using the code above) and it prints bigger and in poor guality.
I figured out (simple math) that java prints by 75% bigger any graphic than it's real size. I scale it down by
Code:
g2d.drawImage(headerLogo, x, y, headerLogo.getWidth() * 75/100, headerLogo.getHeight() * 75/100, imageObserver);
and using these rentering hints
Code:
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
But the result is really really disappointing!
What am I doing wrong ?
-
April 21st, 2014, 06:22 AM
#3
Re: How to print images correctly
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|