This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

quickly increase the height of an image  RSS feed

 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a code block I haven't touched in a while that goes into detail creating an image that has some text and boxes on it, etc. Usually this image is meant to be printed from within a webpage, and I have no problems with that, but sometimes it needs to be printed by itself. If you open it with the Windows Picture and Fax Viewer that comes with Windows XP (the default viewer), and then click the print icon, it takes you into a Photo Printing Wizard that always automatically rotates this image to landscape (and blows it up to 100% of the page). It's crucial that no one tries to print the image at this size, and there's no way around it in this wizard. I'm thinking it's trying to rotate the image because it's 669 pixels wide and 528 pixels tall (it really needs to be printed in portrait, though).

So, I'm trying to come up with a hack. The hack is this: for when it needs to be printed by itself and not in a webpage, I want to write out a second version of the image that's the same width, but I'd like to tack on another 500 pixels or so to the height so that that wizard will never try to rotate it or blow it up (Windows 2000 people never have a problem printing this thing because they don't have this nutzo wizard). I'm using a Graphics2D, and after painting the whole thing, I'm writing it out with a BufferedImage like so:



I'm adding another line right after it for the other image, like this:



Is there something quick and easy I can do to the image between file writes so that I can tack an extra several hundred pixels onto the height of the image?

Thanks!
[ August 03, 2004: Message edited by: Karelicek Huey ]
 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I think I have an answer to my question:



That works fine, except that except for where the original image is taking up the space of the taller Graphics2D, the color is black. See how I'm trying to set the rest of the image's color to white? It's not working....
 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind. Graphics2D has a great method called clearRect! Only thing is, now when I go into that annoying XP Photo Wizard, it doesn't try to rotate it but there is still a possible problem. The first of the 2 Full Page options is Fax Print, and the other is supposedly for photos. The Fax Print says it centers and rotates it to fit, whereas the other says it crops and rotates to fit. Well, neither is trying to rotate my heightened image (how often do you get to say heightened?), but the photo one seems to be cropping it because it gets distorted a little (slightly blown up). What I'm trying to figure out is if there is some pixel width I can increase my image to so that it doesn't do that but I can still make sure it fits fine on an 8 x 11.5 inch page. Is an 8 x 11.5 inch page supposed to be a certain number of pixels wide on everyone's computer/printer?
[ August 03, 2004: Message edited by: Karelicek Huey ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!