Scaling more than one object when printing?

E

Elliot

Hi all,

I'm using the following code to scale a jpg that I've loaded off disk
in a Java application:

Graphics2D g2d = (Graphics2D)g;
g2d.translate(x0,y0 );
g2d.scale( scaleFactor,scaleFactor );
AffineTransform at = AffineTransform.getTranslateInstance(x0,y0);
BufferedImage bufImage = this.toBufferedImage(this.imgSource);
g2d.drawRenderedImage(bufImage, at);

The image scales correctly as determined by "scaleFactor", however I
also have some rectangles on the same page and they are scaling as
well. How do I apply the transformation just to the image and not to
everything else on the page?

Thanks

Elliot
 
H

Hunter Gratzner

I'm using the following code to scale a jpg that I've loaded off disk
in a Java application:

Graphics2D g2d = (Graphics2D)g;
g2d.translate(x0,y0 );
g2d.scale( scaleFactor,scaleFactor );
AffineTransform at = AffineTransform.getTranslateInstance(x0,y0);
BufferedImage bufImage = this.toBufferedImage(this.imgSource);
g2d.drawRenderedImage(bufImage, at);

The image scales correctly as determined by "scaleFactor", however I
also have some rectangles on the same page and they are scaling as
well. How do I apply the transformation just to the image and not to
everything else on the page?

Do the obvious. Either draw that other stuff before you scale, or
reset g2d to its original transformation after you have drawn the
image.
 
E

Elliot

Do the obvious. Either draw that other stuff before you scale, or
reset g2d to its original transformation after you have drawn the
image.

Thanks for the ideas
Elliot
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top