void FindTheSpotGameEngine::Render(CIwRect& bounds) { CIwSVec2 imgBounds(bounds.x, bounds.y); Utils::AlphaRenderImage(g_pLogoTexture, imgBounds, 0xff); float tileSize = 160.0f; if (g_finalScore == 0) { CIwRect tileBounds(bounds.x + (bounds.w - tileSize) / 2, bounds.y + (bounds.h - tileSize) / 2, tileSize, tileSize); Utils::AlphaRenderImage(g_pTile, tileBounds, 255); CIwColour white; white.Set(0xff, 0xff, 0xff, 0x7f); float scale = tileSize / 256.0f; Iw2DSetColour(white); Iw2DDrawRect(CIwSVec2(tileBounds.x-1, tileBounds.y-1), CIwSVec2(tileBounds.w+2, tileBounds.h+2)); CIwSVec2 spotLoc(tileBounds.x + (g_tileLoc.x * scale) - (g_pCursorTexture->GetWidth() / 2), tileBounds.y + (g_tileLoc.y * scale) - (g_pCursorTexture->GetHeight() / 2)); Utils::AlphaRenderImage(g_pCursorTexture, spotLoc, 255); if (g_renderTemp == 1) { CIwSVec2 imgBounds(bounds.x, bounds.y + bounds.h - g_pColderTexture->GetHeight()); Utils::AlphaRenderImage(g_pColderTexture, imgBounds, 255); } else if (g_renderTemp == 2) { CIwSVec2 imgBounds(bounds.x, bounds.y + bounds.h - g_pHotterTexture->GetHeight()); Utils::AlphaRenderImage(g_pHotterTexture, imgBounds, 255); } } else { tileSize = g_pFoundTexture->GetWidth(); CIwRect tileBounds(bounds.x + (bounds.w - tileSize) / 2, bounds.y + (bounds.h - tileSize) / 2, tileSize, tileSize); Utils::AlphaRenderImage(g_pFoundTexture, tileBounds, 255); } }
//! Adapts image viewer's affine to display the passed viewer rect at maximized //! ratio void ImageViewer::adaptView(const QRect &geomRect) { if (!m_image) return; // Retrieve the rect in image reference and call the associated adaptView TRect imgBounds(getImageBounds(m_image)); TRectD imgBoundsD(imgBounds.x0, imgBounds.y0, imgBounds.x1 + 1, imgBounds.y1 + 1); TRectD geomRectD(geomRect.left(), geomRect.top(), geomRect.right() + 1, geomRect.bottom() + 1); TRectD viewRectD(getImgToWidgetAffine().inv() * geomRectD); TRect viewRect(tfloor(viewRectD.x0), tfloor(viewRectD.y0), tceil(viewRectD.x1) - 1, tceil(viewRectD.y1) - 1); adaptView(imgBounds, viewRect); }
void ImageViewer::fitView() { if (!m_image) return; TRect imgBounds(getImageBounds(m_image)); adaptView(imgBounds, imgBounds); }