mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Use Images::Read instead of App::readImage.
This commit is contained in:
@@ -45,7 +45,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "mainwindow.h"
|
||||
#include "core/application.h"
|
||||
#include "lottie/lottie_animation.h"
|
||||
#include "app.h"
|
||||
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QMimeType>
|
||||
|
@@ -24,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "core/application.h"
|
||||
#include "storage/file_download.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "app.h"
|
||||
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtGui/QImageReader>
|
||||
@@ -464,11 +463,11 @@ void DocumentMedia::ReadOrGenerateThumbnail(
|
||||
});
|
||||
} else if (active) {
|
||||
crl::async([=] {
|
||||
const auto image = App::readImage(value, nullptr, false);
|
||||
crl::on_main(guard, [=] {
|
||||
auto image = Images::Read({ .content = value }).image;
|
||||
crl::on_main(guard, [=, image = std::move(image)]() mutable {
|
||||
document->setGoodThumbnailChecked(true);
|
||||
if (const auto active = document->activeMediaView()) {
|
||||
active->setGoodThumbnail(image);
|
||||
active->setGoodThumbnail(std::move(image));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "data/data_document_resolver.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "facades.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
@@ -186,22 +185,15 @@ base::binary_guard ReadImageAsync(
|
||||
guard = result.make_guard(),
|
||||
callback = std::move(done)
|
||||
]() mutable {
|
||||
auto format = QByteArray();
|
||||
if (bytes.isEmpty()) {
|
||||
QFile f(path);
|
||||
if (f.size() <= App::kImageSizeLimit
|
||||
&& f.open(QIODevice::ReadOnly)) {
|
||||
bytes = f.readAll();
|
||||
}
|
||||
}
|
||||
auto image = bytes.isEmpty()
|
||||
? QImage()
|
||||
: App::readImage(bytes, &format, false, nullptr);
|
||||
auto read = Images::Read({
|
||||
.path = path,
|
||||
.content = bytes,
|
||||
});
|
||||
if (postprocess) {
|
||||
image = postprocess(std::move(image));
|
||||
read.image = postprocess(std::move(read.image));
|
||||
}
|
||||
crl::on_main(std::move(guard), [
|
||||
image = std::move(image),
|
||||
image = std::move(read.image),
|
||||
callback = std::move(callback)
|
||||
]() mutable {
|
||||
callback(std::move(image));
|
||||
@@ -231,7 +223,7 @@ void ResolveDocument(
|
||||
|
||||
const auto media = document->createMediaView();
|
||||
const auto openImageInApp = [&] {
|
||||
if (document->size >= App::kImageSizeLimit) {
|
||||
if (document->size >= Images::kReadBytesLimit) {
|
||||
return false;
|
||||
}
|
||||
const auto &location = document->location(true);
|
||||
|
@@ -1007,7 +1007,8 @@ WebPageData *MediaWebPage::webpage() const {
|
||||
|
||||
bool MediaWebPage::hasReplyPreview() const {
|
||||
if (const auto document = MediaWebPage::document()) {
|
||||
return document->hasThumbnail() && !document->isPatternWallPaper();
|
||||
return document->hasThumbnail()
|
||||
&& !document->isPatternWallPaper();
|
||||
} else if (const auto photo = MediaWebPage::photo()) {
|
||||
return !photo->isNull();
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "storage/file_download.h"
|
||||
#include "core/application.h"
|
||||
#include "facades.h"
|
||||
#include "app.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
@@ -331,6 +331,15 @@ std::optional<WallPaper> WallPaper::Create(
|
||||
if (!document->checkWallPaperProperties()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
const auto unsupported = data.vsettings()
|
||||
&& data.vsettings()->match([&](const MTPDwallPaperSettings &data) {
|
||||
return data.vsecond_background_color()
|
||||
|| data.vthird_background_color()
|
||||
|| data.vfourth_background_color(); // #TODO themes gradients
|
||||
});
|
||||
if (unsupported) {
|
||||
return std::nullopt;
|
||||
}
|
||||
auto result = WallPaper(data.vid().v);
|
||||
result._accessHash = data.vaccess_hash().v;
|
||||
result._ownerId = session->userId();
|
||||
|
@@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_file_origin.h"
|
||||
#include "storage/file_download.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "app.h"
|
||||
|
||||
namespace Data {
|
||||
|
||||
@@ -28,7 +27,7 @@ not_null<StickersSet*> StickersSetThumbnailView::owner() const {
|
||||
void StickersSetThumbnailView::set(
|
||||
not_null<Main::Session*> session,
|
||||
QByteArray content) {
|
||||
auto image = App::readImage(content, nullptr, false);
|
||||
auto image = Images::Read({ .content = content }).image;
|
||||
if (image.isNull()) {
|
||||
_content = std::move(content);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user