Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Help printing images

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help printing images

    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

    Graphics g;
    g.drawImage(headerLogo, x, y, headerLogo.getWidth(), headerLogo.getHeight(), imageObserver);

    What may be wrong ?


  2. #2
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help printing images

    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

    g2d.drawImage(headerLogo, x, y, headerLogo.getWidth() * 75/100, headerLogo.getHeight() * 75/100, imageObserver);

    and using these rentering hints

    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 ?

  3. #3
    Member
    Join Date
    Dec 2013
    Location
    Honolulu
    Posts
    83
    Thanks
    1
    Thanked 4 Times in 2 Posts

    Default Re: Help printing images

    If you want to you can just use NetBean, java. It's free on Sun Microsystem inc. website. Here is the scanner on my home PC.

    HP Deskjet 2540 series with scanner/printerStarAdvertiser_Newspaper.jpg
    Last edited by planetHollywood; April 25th, 2014 at 02:20 AM. Reason: HP Deskjet 2540 series printer

  4. #4
    Member
    Join Date
    Dec 2013
    Location
    Honolulu
    Posts
    83
    Thanks
    1
    Thanked 4 Times in 2 Posts

    Default Re: Help printing images

    Java Objects.jpg Here is the book I am reading now. It is a good conceptual and object oriented book.

  5. #5
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help printing images

    I'm sorry, but what all these have to do with my question ?

  6. #6
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Help printing images

    Can you post an SSCCE that demonstrates the problem and shows the code from opening, processing, rendering, and printing?

Similar Threads

  1. Printing Images using java
    By lsorsby in forum What's Wrong With My Code?
    Replies: 0
    Last Post: July 17th, 2013, 09:13 AM
  2. Images
    By Hoshi in forum Java Theory & Questions
    Replies: 1
    Last Post: September 6th, 2012, 10:54 PM
  3. Replies: 1
    Last Post: September 28th, 2011, 07:29 AM
  4. [SOLVED] Help needed with Images.
    By Brt93yoda in forum What's Wrong With My Code?
    Replies: 19
    Last Post: August 16th, 2010, 04:46 PM
  5. [SOLVED] Printing Array without printing empty elements
    By CarlMartin10 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 12th, 2010, 02:41 AM