void Graphics::drawImageWithin (const Image& imageToDraw, const int destX, const int destY, const int destW, const int destH, const RectanglePlacement& placementWithinTarget, const bool fillAlphaChannelWithCurrentBrush) const { // passing in a silly number can cause maths problems in rendering! jassert (areCoordsSensibleNumbers (destX, destY, destW, destH)); if (imageToDraw.isValid()) { const int imageW = imageToDraw.getWidth(); const int imageH = imageToDraw.getHeight(); if (imageW > 0 && imageH > 0) { double newX = 0.0, newY = 0.0; double newW = imageW; double newH = imageH; placementWithinTarget.applyTo (newX, newY, newW, newH, destX, destY, destW, destH); if (newW > 0 && newH > 0) { drawImage (imageToDraw, roundToInt (newX), roundToInt (newY), roundToInt (newW), roundToInt (newH), 0, 0, imageW, imageH, fillAlphaChannelWithCurrentBrush); } } } }
void QuickTimeMovieComponent::setBoundsWithCorrectAspectRatio (const Rectangle& spaceToFitWithin, const RectanglePlacement& placement) { int normalWidth, normalHeight; getMovieNormalSize (normalWidth, normalHeight); if (normalWidth > 0 && normalHeight > 0 && ! spaceToFitWithin.isEmpty()) { double x = 0.0, y = 0.0, w = normalWidth, h = normalHeight; placement.applyTo (x, y, w, h, spaceToFitWithin.getX(), spaceToFitWithin.getY(), spaceToFitWithin.getWidth(), spaceToFitWithin.getHeight()); if (w > 0 && h > 0) { setBounds (roundToInt (x), roundToInt (y), roundToInt (w), roundToInt (h)); } } else { setBounds (spaceToFitWithin); } }
void drawCurrentImage (Graphics& g, int x, int y, int w, int h) { if (imageNeedsFlipping) { const ScopedLock sl (imageSwapLock); std::swap (loadingImage, activeImage); imageNeedsFlipping = false; } RectanglePlacement rp (RectanglePlacement::centred); double dx = 0, dy = 0, dw = width, dh = height; rp.applyTo (dx, dy, dw, dh, x, y, w, h); const int rx = roundToInt (dx), ry = roundToInt (dy); const int rw = roundToInt (dw), rh = roundToInt (dh); { Graphics::ScopedSaveState ss (g); g.excludeClipRegion (Rectangle<int> (rx, ry, rw, rh)); g.fillAll (Colours::black); } g.drawImage (activeImage, rx, ry, rw, rh, 0, 0, width, height); }