Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   drawImage (http://www.velocityreviews.com/forums/t956672-drawimage.html)

bob smith 01-18-2013 09:53 PM

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

http://docs.oracle.com/javase/1.4.2/.../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?

Daniel Pitts 01-18-2013 09:57 PM

Re: drawImage
 
On 1/18/13 1:53 PM, bob smith wrote:
> I'm looking at the drawImage routines in the Graphics class:
>
> http://docs.oracle.com/javase/1.4.2/.../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.




Roedy Green 01-18-2013 10:53 PM

Re: drawImage
 
On Fri, 18 Jan 2013 13:53:05 -0800 (PST), bob smith
<bob@coolfone.comze.com> wrote, quoted or indirectly quoted someone
who said :

>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

Lew 01-19-2013 12:44 AM

Re: drawImage
 
Daniel Pitts wrote:
>bob smith wrote:
>> I'm looking at the drawImage routines in the Graphics class:
>> http://docs.oracle.com/javase/1.4.2/.../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.


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.

--
Lew


All times are GMT. The time now is 01:51 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57