mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Use Images::Read instead of App::readImage.
This commit is contained in:
@@ -23,7 +23,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "core/crash_reports.h"
|
||||
#include "base/bytes.h"
|
||||
#include "base/openssl_help.h"
|
||||
#include "app.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -163,11 +162,10 @@ void FileLoader::readImage(int progressiveSizeLimit) const {
|
||||
const auto buffer = progressiveSizeLimit
|
||||
? QByteArray::fromRawData(_data.data(), progressiveSizeLimit)
|
||||
: _data;
|
||||
auto format = QByteArray();
|
||||
auto image = App::readImage(buffer, &format, false);
|
||||
if (!image.isNull()) {
|
||||
_imageData = std::move(image);
|
||||
_imageFormat = format;
|
||||
auto read = Images::Read({ .content = buffer });
|
||||
if (!read.image.isNull()) {
|
||||
_imageData = std::move(read.image);
|
||||
_imageFormat = read.format;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,13 +288,12 @@ void FileLoader::loadLocal(const Storage::Cache::Key &key) {
|
||||
value = std::move(value),
|
||||
done = std::move(callback)
|
||||
]() mutable {
|
||||
auto format = QByteArray();
|
||||
auto image = App::readImage(value, &format, false);
|
||||
if (!image.isNull()) {
|
||||
auto read = Images::Read({ .content = value });
|
||||
if (!read.image.isNull()) {
|
||||
done(
|
||||
std::move(value),
|
||||
std::move(image),
|
||||
std::move(format));
|
||||
std::move(read.image),
|
||||
std::move(read.format));
|
||||
} else {
|
||||
done(std::move(value), {}, {});
|
||||
}
|
||||
|
@@ -31,7 +31,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
#include "main/main_session.h"
|
||||
#include "app.h"
|
||||
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtGui/QImageWriter>
|
||||
@@ -642,25 +641,25 @@ bool FileLoadTask::CheckForImage(
|
||||
const QString &filepath,
|
||||
const QByteArray &content,
|
||||
std::unique_ptr<Ui::PreparedFileInformation> &result) {
|
||||
auto animated = false;
|
||||
auto image = [&] {
|
||||
auto read = [&] {
|
||||
if (filepath.endsWith(qstr(".tgs"), Qt::CaseInsensitive)) {
|
||||
auto image = Lottie::ReadThumbnail(
|
||||
Lottie::ReadContent(content, filepath));
|
||||
if (!image.isNull()) {
|
||||
animated = true;
|
||||
const auto success = !image.isNull();
|
||||
if (success) {
|
||||
result->filemime = qstr("application/x-tgsticker");
|
||||
}
|
||||
return image;
|
||||
return Images::ReadResult{
|
||||
.image = std::move(image),
|
||||
.animated = success,
|
||||
};
|
||||
}
|
||||
if (!content.isEmpty()) {
|
||||
return App::readImage(content, nullptr, false, &animated);
|
||||
} else if (!filepath.isEmpty()) {
|
||||
return App::readImage(filepath, nullptr, false, &animated);
|
||||
}
|
||||
return QImage();
|
||||
return Images::Read({
|
||||
.path = filepath,
|
||||
.content = content,
|
||||
});
|
||||
}();
|
||||
return FillImageInformation(std::move(image), animated, result);
|
||||
return FillImageInformation(std::move(read.image), read.animated, result);
|
||||
}
|
||||
|
||||
bool FileLoadTask::FillImageInformation(
|
||||
|
@@ -14,7 +14,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/image/image_prepare.h"
|
||||
#include "ui/chat/attach/attach_extensions.h"
|
||||
#include "ui/chat/attach/attach_prepare.h"
|
||||
#include "app.h"
|
||||
|
||||
#include <QtCore/QSemaphore>
|
||||
#include <QtCore/QMimeData>
|
||||
@@ -164,7 +163,7 @@ MimeDataState ComputeMimeDataState(const QMimeData *data) {
|
||||
if (filesize > kFileSizeLimit) {
|
||||
return MimeDataState::None;
|
||||
} else if (allAreSmallImages) {
|
||||
if (filesize > App::kImageSizeLimit) {
|
||||
if (filesize > Images::kReadBytesLimit) {
|
||||
allAreSmallImages = false;
|
||||
} else if (!HasExtensionFrom(file, imageExtensions)) {
|
||||
allAreSmallImages = false;
|
||||
|
Reference in New Issue
Block a user