drawImage

B

bob smith

I'm looking at the drawImage routines in the Graphics class:

http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics.html

I noticed all of them take integers for the x, y, width, height.

This is not necessarily the best thing since you may have a matrix that scales the canvas by… say 1000 times. Then, it might make sense to have a float passed in.

Maybe there should be drawImageF versions or something so we can pass floats in?

Any ideas?
 
D

Daniel Pitts

I'm looking at the drawImage routines in the Graphics class:

http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics.html

I noticed all of them take integers for the x, y, width, height.

This is not necessarily the best thing since you may have a matrix that scales the canvas by… say 1000 times. Then, it might make sense to have a float passed in.

Maybe there should be drawImageF versions or something so we can pass floats in?

Any ideas?
First off, you're looking at the wrong class.
Second off, you're looking at a very old version of the wrong class.

<http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics2D.html>

If you look in here, you'll see there is a method which takes an image
and an AffineTransform instance.
 
R

Roedy Green

I noticed all of them take integers for the x, y, width, height. =20

Sun had the same thought. Have a look at Graphics2D where there are
AffineTransforms and double/float versions of a number of the methods,
but not all!

See http://mindprod.com/jgloss/graphics2d.html
http://mindprod.com/jgloss/affinetransform.html

--
Roedy Green Canadian Mind Products http://mindprod.com
The first 90% of the code accounts for the first 90% of the development time.
The remaining 10% of the code accounts for the other 90% of the development
time.
~ Tom Cargill Ninety-ninety Law
 
L

Lew

Daniel said:
First off, you're looking at the wrong class.
Second off, you're looking at a very old version of the wrong class.

<http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics2D.html>

If you look in here, you'll see there is a method which takes an image
and an AffineTransform instance.

And on other methods you'll see, e.g., not two but four 'drawString()' overloads that, like
the 'drawImage()' overloads, do not bother with naming the method differently.

That "F" wart in the name 'drawImageF' is not necessary. Also, it is not compliant with the
Java Coding Conventions.

Some argue against overloads. I say use them if they suit. One place they do not is factory
methods.
 

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

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,158
Latest member
Vinay_Kumar Nevatia
Top