From f2866442d2c7fd47427b0ab570b5bf69f79706b8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 16 Oct 2018 12:05:32 +0300 Subject: [PATCH] Fix location thumb image sizes --- .../SourceFiles/history/history_location_manager.cpp | 6 +++--- Telegram/SourceFiles/history/history_media_types.cpp | 12 +----------- .../SourceFiles/inline_bots/inline_bot_result.cpp | 4 ++-- Telegram/SourceFiles/ui/images.cpp | 4 ++-- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/Telegram/SourceFiles/history/history_location_manager.cpp b/Telegram/SourceFiles/history/history_location_manager.cpp index 57d4b33a7..79e3592d3 100644 --- a/Telegram/SourceFiles/history/history_location_manager.cpp +++ b/Telegram/SourceFiles/history/history_location_manager.cpp @@ -18,9 +18,9 @@ constexpr auto kMaxHttpRedirects = 5; GeoPointLocation ComputeLocation(const LocationCoords &coords) { const auto scale = 1 + (cScale() * cIntRetinaFactor()) / 200; - const auto zoom = 15 + (scale - 1); - const auto w = ConvertScale(st::locationSize.width()) / scale; - const auto h = ConvertScale(st::locationSize.height()) / scale; + const auto zoom = 13 + (scale - 1); + const auto w = st::locationSize.width() / scale; + const auto h = st::locationSize.height() / scale; auto result = GeoPointLocation(); result.lat = coords.lat(); diff --git a/Telegram/SourceFiles/history/history_media_types.cpp b/Telegram/SourceFiles/history/history_media_types.cpp index f2c5a8535..86dd82978 100644 --- a/Telegram/SourceFiles/history/history_media_types.cpp +++ b/Telegram/SourceFiles/history/history_media_types.cpp @@ -4829,17 +4829,7 @@ void HistoryLocation::draw(Painter &p, const QRect &r, TextSelection selection, | (isBubbleBottom() ? (RectPart::BottomLeft | RectPart::BottomRight) : RectPart::None); auto rthumb = QRect(paintx, painty, paintw, painth); if (_data && !_data->thumb->isNull()) { - auto w = _data->thumb->width(), h = _data->thumb->height(); - QPixmap pix; - if (paintw * h == painth * w || (w == fullWidth() && h == fullHeight())) { - pix = _data->thumb->pixSingle(contextId, paintw, painth, paintw, painth, roundRadius, roundCorners); - } else if (paintw * h > painth * w) { - auto nw = painth * w / h; - pix = _data->thumb->pixSingle(contextId, nw, painth, paintw, painth, roundRadius, roundCorners); - } else { - auto nh = paintw * h / w; - pix = _data->thumb->pixSingle(contextId, paintw, nh, paintw, painth, roundRadius, roundCorners); - } + const auto &pix = _data->thumb->pixSingle(contextId, paintw, painth, paintw, painth, roundRadius, roundCorners); p.drawPixmap(rthumb.topLeft(), pix); } else { App::complexLocationRect(p, rthumb, roundRadius, roundCorners); diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp index 0c89eaaa1..f27f65718 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp @@ -225,8 +225,8 @@ std::unique_ptr Result::create(uint64 queryId, const MTPBotInlineResult if (result->getLocationCoords(&coords)) { const auto scale = 1 + (cScale() * cIntRetinaFactor()) / 200; const auto zoom = 15 + (scale - 1); - const auto w = ConvertScale(st::inlineThumbSize) / scale; - const auto h = ConvertScale(st::inlineThumbSize) / scale; + const auto w = st::inlineThumbSize / scale; + const auto h = st::inlineThumbSize / scale; auto location = GeoPointLocation(); location.lat = coords.lat(); diff --git a/Telegram/SourceFiles/ui/images.cpp b/Telegram/SourceFiles/ui/images.cpp index 977a692fa..e45cf5d51 100644 --- a/Telegram/SourceFiles/ui/images.cpp +++ b/Telegram/SourceFiles/ui/images.cpp @@ -1245,11 +1245,11 @@ std::optional GeoPointImage::cacheKey() const { } int GeoPointImage::countWidth() const { - return _location.width; + return _location.width * _location.scale; } int GeoPointImage::countHeight() const { - return _location.height; + return _location.height * _location.scale; } void GeoPointImage::setInformation(int size, int width, int height) {