Fix location thumb image sizes

This commit is contained in:
John Preston 2018-10-16 12:05:32 +03:00
parent 3cdfa1014a
commit f2866442d2
4 changed files with 8 additions and 18 deletions

View File

@ -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();

View File

@ -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);

View File

@ -225,8 +225,8 @@ std::unique_ptr<Result> 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();

View File

@ -1245,11 +1245,11 @@ std::optional<Storage::Cache::Key> 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) {