• Post Reply Bookmark Topic Watch Topic
  • New Topic

Printing a BufferedImage

 
Michael Highfill
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to print a BufferedImage that I read from a Robot screen capture (from a class that implements Printable). When I print I only get the top 5-10% of the image and the rest is solid grey. Does anybody have any experience with this problem?

Here is the code:
robot = new Robot();
image = robot.createScreenCapture(
new Rectangle(
(int) (pt.getX()),
(int) (pt.getY()),
width,
height));
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
if(pi >= 1)
{
System.out.println("NO_SUCH_PAGE");
return Printable.NO_SUCH_PAGE;
}
Graphics2D g2d = (Graphics2D)g;
int imageWidth = image.getWidth();
int imageHeight = image.getHeight();
double pageHeight = pf.getImageableHeight();
double pageWidth = pf.getImageableWidth();
g2d.translate(pf.getImageableX(), pf.getImageable());
g2d.drawImage(image, new AffineTransform(), this);
return Printable.PAGE_EXISTS;
 
Michael Highfill
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found my problem. The print dialog box was blocking out my image. The solution is to refresh the image just before it is captured.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!