Glen F - 2005-01-28

Logged In: YES
user_id=1206567

Here's some code for a local method I wrote to do this for
me - if you like the idea, you can move it into the GraphicsKit.

void drawImageToBounds(GraphicsContext* ctx, Rect*
rBound, Image* imgDraw)
{
// Get the current scaling in affect
double dblOrigX = ctx->getScaleX();
double dblOrigY = ctx->getScaleY();

// Get the desired change for scaling the image
double dblChangeX = rBound->getWidth() / imgDraw-
>getWidth();
double dblChangeY = rBound->getHeight() /
imgDraw->getHeight();

// Get the reverse-scaled point to draw at
Point pDraw = rBound->getTopLeft() / Point
(dblChangeX, dblChangeY);

// Get the new scale to apply
double dblNewX = dblOrigX * dblChangeX;
double dblNewY = dblOrigY * dblChangeY;

// Temp - have to adjust X scaling until bug
1110901 is fixed
dblNewX *= 1.33333;
pDraw.x_ /= 1.33333;

// Do the actual scale and draw
ctx->setScale(dblNewX, dblNewY);
ctx->drawImage(pDraw, imgDraw);
ctx->setScale(dblOrigX, dblOrigY);
}