No Graphics::drawImage on float destination coordinates?


#1

Is there a reason there’s no float version of drawImage?

void Graphics::drawImage (const Image& imageToDraw,
                          int dx, int dy, int dw, int dh,
                          int sx, int sy, int sw, int sh,
                          const bool fillAlphaChannelWithCurrentBrush)

It looks like drawImage uses drawImageTransformed which accepts an AffineTransform which is made from floats.

Obviously, the source coordinates are fine being ints, but shouldn’t the dx, dy, dw & dh be floats?


#2

I think there are a few graphics methods like that where it could use an update (but preferable to change it to use a Rectangle than just adding a raw floats version)


#3

Why not both? The code looks trivial and not prone to error.

I would prefer a float version as there already seems to be int and float versions of many other Graphics functions and it would be a simple replacement.


#4

Using Point/Rectangle forces you to write less messy code - if I’d been a bit more experienced 15 years ago when I started that class, I’d have avoided the loose int parameters altogether!


#5

Agreed.

I thought it would be trivial to make a float version but then I noticed that all the clipping code is using ints.