mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Show first frame of webm in photo editor.
This commit is contained in:
parent
b4eb25de58
commit
a6621233d0
2 changed files with 27 additions and 3 deletions
|
@ -34,9 +34,9 @@ ItemSticker::ItemSticker(
|
|||
}
|
||||
const auto updateThumbnail = [=] {
|
||||
const auto guard = gsl::finally([&] {
|
||||
setAspectRatio(_pixmap.isNull()
|
||||
? 1.0
|
||||
: (_pixmap.height() / float64(_pixmap.width())));
|
||||
if (_pixmap.isNull()) {
|
||||
setAspectRatio(1.);
|
||||
}
|
||||
});
|
||||
if (stickerData->isLottie()) {
|
||||
_lottie.player = ChatHelpers::LottiePlayerFromDocument(
|
||||
|
@ -54,6 +54,25 @@ ItemSticker::ItemSticker(
|
|||
update();
|
||||
}, _lottie.lifetime);
|
||||
return true;
|
||||
} else if (stickerData->isWebm()
|
||||
&& !_document->dimensions.isEmpty()) {
|
||||
const auto callback = [=](::Media::Clip::Notification) {
|
||||
const auto size = _document->dimensions;
|
||||
if (_webm && _webm->ready() && !_webm->started()) {
|
||||
_webm->start({ .frame = size, .keepAlpha = true });
|
||||
}
|
||||
if (_webm && _webm->started()) {
|
||||
updatePixmap(_webm->current(
|
||||
{ .frame = size, .keepAlpha = true },
|
||||
0));
|
||||
_webm = nullptr;
|
||||
}
|
||||
};
|
||||
_webm = ::Media::Clip::MakeReader(
|
||||
_mediaView->owner()->location(),
|
||||
_mediaView->bytes(),
|
||||
callback);
|
||||
return true;
|
||||
}
|
||||
const auto sticker = _mediaView->getStickerLarge();
|
||||
if (!sticker) {
|
||||
|
@ -83,6 +102,9 @@ void ItemSticker::updatePixmap(QPixmap &&pixmap) {
|
|||
} else {
|
||||
update();
|
||||
}
|
||||
if (!_pixmap.isNull()) {
|
||||
setAspectRatio(_pixmap.height() / float64(_pixmap.width()));
|
||||
}
|
||||
}
|
||||
|
||||
void ItemSticker::paint(
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#pragma once
|
||||
|
||||
#include "editor/scene/scene_item_base.h"
|
||||
#include "media/clip/media_clip_reader.h"
|
||||
|
||||
namespace Data {
|
||||
class DocumentMedia;
|
||||
|
@ -47,6 +48,7 @@ private:
|
|||
std::unique_ptr<Lottie::SinglePlayer> player;
|
||||
rpl::lifetime lifetime;
|
||||
} _lottie;
|
||||
::Media::Clip::ReaderPointer _webm;
|
||||
QPixmap _pixmap;
|
||||
|
||||
rpl::lifetime _loadingLifetime;
|
||||
|
|
Loading…
Add table
Reference in a new issue