MCPcopy Create free account
hub / github.com/audacity/audacity / FetchImage

Method FetchImage

modules/sharing/mod-musehub-ui/GetEffectsDialog.cpp:144–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144void GetEffectsDialog::FetchImage(RoundedStaticBitmap* bitmap, const std::string& url)
145{
146 using namespace audacity::network_manager;
147 auto response = NetworkManager::GetInstance().doGet(Request(url));
148
149 response->setRequestFinishedCallback([response, bitmap, self=wxWeakRef(this)] (auto){
150 if (!self) {
151 return;
152 }
153
154 const auto httpCode = response->getHTTPCode();
155 if (httpCode != HttpCode::OK) {
156 return;
157 }
158
159 BasicUI::CallAfter([response, bitmap, self]() {
160 if(!self) {
161 return;
162 }
163
164 auto data = response->readAll<std::vector<uint8_t>>();
165 wxMemoryInputStream memStream(data.data(), data.size());
166 wxImage image;
167
168 if (!image.LoadFile(memStream)) {
169 return;
170 }
171
172 image.Rescale(effectIconWidth, effectPanelHeight, wxIMAGE_QUALITY_HIGH);
173 bitmap->SetImage(image);
174 });
175 });
176}
177
178void GetEffectsDialog::AddLoadingPage() {
179 wxPanel* page = safenew wxPanel();

Callers

nothing calls this directly

Calls 10

CallAfterFunction · 0.85
doGetMethod · 0.80
LoadFileMethod · 0.80
RescaleMethod · 0.80
SetImageMethod · 0.80
RequestFunction · 0.50
getHTTPCodeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected