This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Printing a BufferedImage  RSS feed

 
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!