From ec7312ac13ce19f64b2b453b43e2c37235dcbe7a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 5 May 2014 21:36:16 +0300 Subject: GUI: Implemented more modes to autoscale --- graphics/VectorRendererSpec.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'graphics/VectorRendererSpec.cpp') diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index 1fdd0fc4eb..68b77d20ee 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -886,13 +886,25 @@ blitKeyBitmap(const Graphics::Surface *source, const Common::Rect &r) { template void VectorRendererSpec:: -blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r, bool autoscale) { - if (autoscale) +blitAlphaBitmap(Graphics::TransparentSurface *source, const Common::Rect &r, Graphics::DrawStep::AutoScaleMode autoscale) { + if (autoscale == Graphics::DrawStep::kAutoScaleStretch) { source->blit(*_activeSurface, r.left, r.top, Graphics::FLIP_NONE, nullptr, TS_ARGB(255, 255, 255, 255), r.width(), r.height()); - else + } else if (autoscale == Graphics::DrawStep::kAutoScaleFit) { + double ratio = (double)r.width() / source->w; + double ratio2 = (double)r.height() / source->h; + + if (ratio2 < ratio) + ratio = ratio2; + + source->blit(*_activeSurface, r.left, r.top, Graphics::FLIP_NONE, + nullptr, TS_ARGB(255, 255, 255, 255), + (int)(source->w * ratio), (int)(source->h * ratio)); + + } else { source->blit(*_activeSurface, r.left, r.top); + } } template -- cgit v1.2.3