MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / currentImage

Method currentImage

Telegram/SourceFiles/window/window_media_preview.cpp:456–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

454}
455
456QPixmap MediaPreviewWidget::currentImage() const {
457 const auto blur = Images::PrepareArgs{ .options = Images::Option::Blur };
458 if (_document) {
459 const auto sticker = _document->sticker();
460 const auto webm = sticker && sticker->isWebm();
461 if (sticker && !webm) {
462 if (_cacheStatus != CacheLoaded) {
463 const_cast<MediaPreviewWidget*>(this)->createLottieIfReady(
464 _document);
465 if (_lottie && _lottie->ready()) {
466 return QPixmap();
467 } else if (const auto image
468 = _documentMedia->getStickerLarge()) {
469 const auto s = currentDimensions();
470 _cache = image->pix(s);
471 _cacheStatus = CacheLoaded;
472 } else if (_cacheStatus != CacheThumbLoaded
473 && _document->hasThumbnail()
474 && _documentMedia->thumbnail()) {
475 const auto s = currentDimensions();
476 _cache = _documentMedia->thumbnail()->pix(s, blur);
477 if (_document && _document->emojiUsesTextColor()) {
478 _cache = Ui::PixmapFromImage(
479 Images::Colored(
480 _cache.toImage(),
481 st::windowFg->c));
482 }
483 _cacheStatus = CacheThumbLoaded;
484 }
485 }
486 } else {
487 const_cast<MediaPreviewWidget*>(this)->validateGifAnimation();
488 const auto &gif = (_gif && _gif->started())
489 ? _gif
490 : _gifThumbnail;
491 if (gif && gif->started()) {
492 const auto paused = _controller->isGifPausedAtLeastFor(
493 Window::GifPauseReason::MediaPreview);
494 return QPixmap::fromImage(
495 gif->current(
496 { .frame = currentDimensions(), .keepAlpha = webm },
497 paused ? 0 : crl::now()),
498 Qt::ColorOnly);
499 }
500 if (_cacheStatus != CacheThumbLoaded
501 && _document->hasThumbnail()) {
502 const auto s = currentDimensions();
503 const auto thumbnail = _documentMedia->thumbnail();
504 if (thumbnail) {
505 _cache = thumbnail->pix(s, blur);
506 _cacheStatus = CacheThumbLoaded;
507 } else if (const auto blurred
508 = _documentMedia->thumbnailInline()) {
509 _cache = blurred->pix(s, blur);
510 _cacheStatus = CacheThumbLoaded;
511 }
512 }
513 }

Callers

nothing calls this directly

Calls 15

isWebmMethod · 0.80
createLottieIfReadyMethod · 0.80
getStickerLargeMethod · 0.80
emojiUsesTextColorMethod · 0.80
validateGifAnimationMethod · 0.80
isGifPausedAtLeastForMethod · 0.80
wantedMethod · 0.80
stickerMethod · 0.45
readyMethod · 0.45
hasThumbnailMethod · 0.45
thumbnailMethod · 0.45
startedMethod · 0.45

Tested by

no test coverage detected