Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / August 2003

Tip: Looking for answers? Try searching our database.

Printing BufferedImage witch high resolution

Thread view: 
Andre Brunner - 19 Aug 2003 14:27 GMT
Hello,

I want to print a JPanel with a lot of JTextField's and some JLabels.

Therefor I created a BufferedImage of the JPanel and tried to print
it. The problem is that the resolution of the print is really bad
because when creating the BufferedImage the resolution of the screen
is used and not the printer-resolution!

My question: Is it possible to print the image with a resolution of
600dpi or higher?

The original image is to big for one page so I have to create
subimages via BufferedImage.getSubImage():

The source of the print-method:

public int print(Graphics gra, PageFormat pageFormat, int pageIndex)
throws PrinterException
{
       mybuf = new BufferedImage((int) getSize().getWidth(),
           (int) getSize().getHeight(), BufferedImage.TYPE_INT_ARGB);

       Graphics2D bufGraphics = mybuf.createGraphics();

       paint(bufGraphics);

       Graphics2D graphics = (Graphics2D) gra;
                         .
                         .
                         .

       subImage = mybuf.getSubimage((int) ((positionForWidth) *
width), (int)
                (positionForHeight * height), width, height);
                         .
                         .
                         .
                       
    graphics.drawImage(subImage, 0, 0, null);                      
        return PAGE_EXISTS;
    }
    else
    {
        return NO_SUCH_PAGE;
    }
     
I would be really great if someone is able to help!

Thank you very much

André
Harald Hein - 19 Aug 2003 21:46 GMT
> Therefor I created a BufferedImage of the JPanel and tried to print
> it. The problem is that the resolution of the print is really bad
[quoted text clipped - 3 lines]
> My question: Is it possible to print the image with a resolution of
> 600dpi or higher?

I lost a little bit track of all the printing APIs in Java (1.4 got yet
another one, so we are up to three or four different printing APIs :-
((().

If you use java.awt.print, the easiest is to disable double buffering
of the JPanel. And directly use the paint method of the JPanel in
Printable.print(). To get the desired parts of the JPanel, you should
transform the Graphics2D object, and leave the cutoff to the cliping.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.