MCPcopy Create free account
hub / github.com/MITK/MITK / HandleGET_mxnScreenshot

Method HandleGET_mxnScreenshot

Modules/RESTAPI/src/mitkRenderingController.cpp:2201–2235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2199// ----------------------------------------------------------------------
2200
2201void RenderingController::HandleGET_mxnScreenshot(const httplib::Request& req, httplib::Response& res) const
2202{
2203 if (m_RenderWindowBridge == nullptr || !m_RenderWindowBridge->HasMxNEditorScreenshotProvider())
2204 {
2205 const auto error = ErrorResponse::RenderWindowNotAvailable(req.path);
2206 this->SendErrorResponse(res, 503, error);
2207 return;
2208 }
2209
2210 ScreenshotQueryParams params;
2211 try
2212 {
2213 params = ParseScreenshotQueryParams(req);
2214 }
2215 catch (const InvalidScreenshotRequest& e)
2216 {
2217 this->SendErrorResponse(res, 400, ErrorResponse::InvalidRequest(e.detail, req.path));
2218 return;
2219 }
2220
2221 try
2222 {
2223 const auto imageData = m_RenderWindowBridge->TakeMxNEditorScreenshot(params.size, params.format);
2224 res.status = 200;
2225 res.set_content(
2226 reinterpret_cast<const char*>(imageData.data()),
2227 imageData.size(),
2228 ContentTypeFor(params.format));
2229 }
2230 catch (const std::exception& e)
2231 {
2232 const auto [status, payload] = MapBridgeException(e, req.path);
2233 this->SendErrorResponse(res, status, payload);
2234 }
2235}
2236
2237void RenderingController::HandleGET_mxnWindowScreenshot(const httplib::Request& req, httplib::Response& res) const
2238{

Calls 7

SendErrorResponseMethod · 0.95
ContentTypeForFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45