2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Implement progressive jpeg loading and sending.

This commit is contained in:
John Preston
2020-08-26 17:28:56 +04:00
parent 0888901d79
commit 437c9320cd
22 changed files with 201 additions and 96 deletions

View File

@@ -270,13 +270,15 @@ ImageWithLocation FromPhotoSize(
ImageWithLocation FromImageInMemory(
const QImage &image,
const char *format) {
const char *format,
QByteArray bytes) {
if (image.isNull()) {
return ImageWithLocation();
}
auto bytes = QByteArray();
auto buffer = QBuffer(&bytes);
image.save(&buffer, format);
if (bytes.isEmpty()) {
auto buffer = QBuffer(&bytes);
image.save(&buffer, format);
}
return ImageWithLocation{
.location = ImageLocation(
DownloadLocation{ InMemoryLocation{ bytes } },

View File

@@ -41,7 +41,8 @@ namespace Images {
const MTPVideoSize &size);
[[nodiscard]] ImageWithLocation FromImageInMemory(
const QImage &image,
const char *format);
const char *format,
QByteArray bytes = QByteArray());
[[nodiscard]] ImageLocation FromWebDocument(const MTPWebDocument &document);
} // namespace Images