Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Image not printing

Reply
Thread Tools

Image not printing

 
 
Chris Rehm
Guest
Posts: n/a
 
      07-14-2003
I have some code (included below), which to me looks exactly like the
code I've used elsewhere that works, but the image doesn't print. I just
don't get it.

I have a Rectangle r which is my current bounds rectangle. I want to
scale my image so that it will take up 100 % width and have a
proportional height. So, I figure out how many dots high it will be once
scaled and that is a float called ish.

I put in a few debug prints to check values, and they are coming out
accurate. I get the right height and width from the image
(logolineImage). The image has been loaded long before.

I've tried it without scaling, and without translate, and with just
plain default AffineTransform.

I draw a stroke around the border, and I write some text, all right
before I get to this point. All the other stuff shows up no problem.

AffineTransform imageAT = new AffineTransform();
float ish =
(float) (r.getHeight()
* ((float) logolineImage.getHeight(null)
/ (float) logolineImage.getWidth(null)));

System.out.println("ish " + ish);
System.out.println("image h " + logolineImage.getHeight(null));
System.out.println("image w " + logolineImage.getWidth(null));
System.out.println("r w " + r.getWidth());
System.out.println("r h " + r.getHeight());
imageAT.translate(0., r.getHeight() - ish);

imageAT.scale(
r.getWidth() / (float)logolineImage.getWidth(null),
ish / (float)logolineImage.getHeight(null));

g2.drawImage(logolineImage, imageAT, null);

--
Chris Rehm
http://www.velocityreviews.com/forums/(E-Mail Removed)

Thou shalt not avenge, nor bear any grudge against the children of thy
people, but shalt love thy neighbour as thyself. [Lev. 19:18]

 
Reply With Quote
 
 
 
 
Chris Rehm
Guest
Posts: n/a
 
      07-14-2003
Okay, the problem was apparently not with the printing stuff.

I changed the Image loader from being the

loadedImage = Toolkit.getDefaultToolkit().getImage(imageName);

That I use for my other printing and displaying, and which worked for
this same image for display, to:

try
{
logolineImage = ImageIO.read(new File(imageName));
}
catch (Exception e)
{
logolineImage = Toolkit.getDefaultToolkit().getImage(imageName);
System.out.println("Could not IO load file " + imageName);
}

and now it prints okay. I do not know why this image, also a jpg created
with the same program I created my other images, fails to load
correctly. Any ideas would be welcome, but at least I've got it rolling
now.

--
Chris Rehm
(E-Mail Removed)

Thou shalt not avenge, nor bear any grudge against the children of thy
people, but shalt love thy neighbour as thyself. [Lev. 19:18]

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 2 11-27-2010 12:12 PM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:52 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:50 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:28 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-18-2007 10:11 AM



Advertisments