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

Method image

Telegram/SourceFiles/data/data_reply_preview.cpp:66–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66Image *ReplyPreview::image(
67 Data::FileOrigin origin,
68 not_null<PeerData*> context,
69 bool spoiler) {
70 auto &image = spoiler ? _spoilered : _regular;
71 auto &checked = spoiler ? _checkedSpoilered : _checkedRegular;
72 if (checked) {
73 return image.get();
74 } else if (_document) {
75 if (!image || (!_good && _document->hasThumbnail())) {
76 if (!_documentMedia) {
77 _documentMedia = _document->createMediaView();
78 _documentMedia->thumbnailWanted(origin);
79 }
80 const auto thumbnail = _documentMedia->thumbnail();
81 const auto option = _document->isVideoMessage()
82 ? Images::Option::RoundCircle
83 : Images::Option::None;
84 if (spoiler) {
85 if (const auto image = _documentMedia->thumbnailInline()) {
86 prepare(image, option, true);
87 } else if (thumbnail) {
88 prepare(thumbnail, option, true);
89 }
90 } else if (thumbnail) {
91 prepare(thumbnail, option);
92 } else if (!image) {
93 if (const auto image = _documentMedia->thumbnailInline()) {
94 prepare(image, option | Images::Option::Blur);
95 }
96 }
97 if (_good || !_document->hasThumbnail()) {
98 checked = true;
99 _documentMedia = nullptr;
100 }
101 }
102 } else {
103 Assert(_photo != nullptr);
104 if (!image || !_good) {
105 const auto inlineThumbnailBytes = _photo->inlineThumbnailBytes();
106 if (!_photoMedia) {
107 _photoMedia = _photo->createMediaView();
108 }
109 using Size = PhotoSize;
110 const auto loadThumbnail = inlineThumbnailBytes.isEmpty()
111 || (!spoiler
112 && _photoMedia->autoLoadThumbnailAllowed(context));
113 if (loadThumbnail) {
114 _photoMedia->wanted(Size::Small, origin);
115 }
116 if (spoiler) {
117 if (const auto blurred = _photoMedia->thumbnailInline()) {
118 prepare(blurred, {}, true);
119 } else if (const auto small = _photoMedia->image(Size::Small)) {
120 prepare(small, {}, true);
121 } else if (const auto large = _photoMedia->image(Size::Large)) {
122 prepare(large, {}, true);
123 }

Callers

nothing calls this directly

Calls 11

thumbnailWantedMethod · 0.80
isVideoMessageMethod · 0.80
wantedMethod · 0.80
getMethod · 0.45
hasThumbnailMethod · 0.45
createMediaViewMethod · 0.45
thumbnailMethod · 0.45
thumbnailInlineMethod · 0.45
inlineThumbnailBytesMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected