Image not printing

C

Chris Rehm

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
(e-mail address 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]
 
C

Chris Rehm

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 address 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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top