-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0
-
beta
-
x86
-
windows_95
Name: diC59631 Date: 10/29/98
Run the following program on jdk1.2rc1 on Windows95. I am trying to render a BufferedImage of type TYPE_BYTE_BINARY to a printed page. The printer is an HP LaserJet 4L for what thats worth. It throws an IllegalArgumentException like this:
java.lang.IllegalArgumentException: Raster BytePackedRaster: width = 1820 height
= 48 #channels 1 xOff = 0 yOff = 0 is incompatible with ColorModel IndexColorMo
del: #pixelBits = 1 numComponents = 4 color space = java.awt.color.ICC_ColorSpac
e@f8912ce0 transparency = 2 transIndex = 2 has alpha = true isAlphaPre = false
at sun.java2d.SunGraphics2D.renderingPipeImage(Compiled Code)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:1769)
at sun.awt.image.BufferedImageGraphics2D.drawImage(BufferedImageGraphics
2D.java:496)
at sun.java2d.SunGraphics2D.drawRenderedImage(Compiled Code)
at sun.java2d.ProxyGraphics2D.drawRenderedImage(ProxyGraphics2D.java:107
6)
at PTest2.print(PTest2.java:61)
at sun.java2d.RasterPrinterJob.printPage(Compiled Code)
at sun.java2d.RasterPrinterJob.print(Compiled Code)
at PTest2.main(PTest2.java:32)
I think you should be allowed to draw any BufferedImage onto any Graphics2D, but perhaps this is not a valid assumption.
Here is the program:
--------------------------------------
import java.awt.*;
import java.awt.image.*;
import java.awt.geom.*;
import java.awt.image.renderable.*;
import java.awt.event.*;
import java.awt.print.*;
import java.util.*;
public class PTest2 implements Printable
{
public static void main(String args[])
{
try {
PrinterJob pj = null;
pj = PrinterJob.getPrinterJob();
Book b = new Book();
PageFormat pf = new PageFormat();
PTest2 ni = new PTest2();
b.append(ni, pf);
pj.setPageable(b);
pj.print();
}
catch(Exception ex) {
ex.printStackTrace();
}
System.exit(0);
}
private RenderedImage myRenderedPage;
public PTest2()
{
myRenderedPage = new BufferedImage(1696, 2175, BufferedImage.TYPE_BYTE_BINARY);
}
public int print(Graphics g, PageFormat pf, int pageIndex)
{
Graphics2D g2 = (Graphics2D)g;
g2.setFont(new Font("SansSerif", Font.PLAIN, 24));
g2.setColor(Color.black);
g2.drawString("Painted Text", 100, 100);
AffineTransform nt = new AffineTransform();
nt.scale(0.3d, 0.3d);
g2.drawRenderedImage(myRenderedPage, nt);
return Printable.PAGE_EXISTS;
}
}
(Review ID: 41539)
======================================================================