Patrix78
asked on
[java.awt.print] How print in grayscale ?
Hello
I use the java.awt.print for printing.
but i do not find the way to print in grayscale
how program the PrinterJob in order to print in grayscale?
Patrice
I use the java.awt.print for printing.
but i do not find the way to print in grayscale
how program the PrinterJob in order to print in grayscale?
Patrice
I think you have to give params to the Colorspace.
ASKER
My code for printing is (sorry for the presentation of the code)
public int print(Graphics g,PageFormat pageFormat,int pageIndex) throws PrinterException
{
if (pageIndex>nombreDePages-1 )
return NO_SUCH_PAGE;
else
this.numeroDePage=pageInde x+1;
Graphics2D g2D = (Graphics2D)g;
if (this.mode==Print.NORMAL_P AGE)
{
if (pageOrientation==PageForm at.PORTRAI T)
g2D.scale(0.92,1);
else
g2D.scale(0.95,1);
}
g2D.translate(12,12);
paint(g2D);
return PAGE_EXISTS;
}
In fact, i think i need to apply the filter to the g2D object, but i do nok know how redrawn the g2D in grayscale
maybe i need to extract the Image object of the g2D,
and redraw with g2D.drawImage(new ColorConvertOp(ColorSpace. getInstanc e(ColorSpa ce.CS_GRAY , null)
it's the way to follow?
regards
Patrice
public int print(Graphics g,PageFormat pageFormat,int pageIndex) throws PrinterException
{
if (pageIndex>nombreDePages-1
return NO_SUCH_PAGE;
else
this.numeroDePage=pageInde
Graphics2D g2D = (Graphics2D)g;
if (this.mode==Print.NORMAL_P
{
if (pageOrientation==PageForm
g2D.scale(0.92,1);
else
g2D.scale(0.95,1);
}
g2D.translate(12,12);
paint(g2D);
return PAGE_EXISTS;
}
In fact, i think i need to apply the filter to the g2D object, but i do nok know how redrawn the g2D in grayscale
maybe i need to extract the Image object of the g2D,
and redraw with g2D.drawImage(new ColorConvertOp(ColorSpace.
it's the way to follow?
regards
Patrice
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.