P
Patrick Boulay
Hi,
I load a TIFF file into a Image object with the dimension 1680x2171. I
want to print it and fit on page on my print in the printer resolution
(like my printer 600 dpi).
I try a lot of different way... I got a lot of problem...
I print a little part of the picture (because the image it's too big).
If I scale it, I lose quality.
Look my code:
public void doprint() {
PrinterJob printJob = PrinterJob.getPrinterJob();
PageFormat pf = printJob.defaultPage();
printJob.setPrintable(this,pf);
if (printJob.printDialog()) {
try {
printJob.print();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
public int print(Graphics g, PageFormat pageFormat, int pi) throws
PrinterException {
if (pi >= 1) {
return Printable.NO_SUCH_PAGE;
}
Graphics2D g2d = (Graphics2D)g;
g2d.drawImage(_image, 0, 0,this);
print(g2d);
return Printable.PAGE_EXISTS;
}
Anyone can help me?
Patrick
I load a TIFF file into a Image object with the dimension 1680x2171. I
want to print it and fit on page on my print in the printer resolution
(like my printer 600 dpi).
I try a lot of different way... I got a lot of problem...
I print a little part of the picture (because the image it's too big).
If I scale it, I lose quality.
Look my code:
public void doprint() {
PrinterJob printJob = PrinterJob.getPrinterJob();
PageFormat pf = printJob.defaultPage();
printJob.setPrintable(this,pf);
if (printJob.printDialog()) {
try {
printJob.print();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
public int print(Graphics g, PageFormat pageFormat, int pi) throws
PrinterException {
if (pi >= 1) {
return Printable.NO_SUCH_PAGE;
}
Graphics2D g2d = (Graphics2D)g;
g2d.drawImage(_image, 0, 0,this);
print(g2d);
return Printable.PAGE_EXISTS;
}
Anyone can help me?
Patrick