| 142 | } |
| 143 | |
| 144 | void 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 | |
| 178 | void GetEffectsDialog::AddLoadingPage() { |
| 179 | wxPanel* page = safenew wxPanel(); |
nothing calls this directly
no test coverage detected