MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / Magick2QImage

Method Magick2QImage

src/MagickUtilities.cpp:45–71  ·  view source on GitHub ↗

Get pointer to QImage conversion of a Magick::Image

Source from the content-addressed store, hash-verified

43
44// Get pointer to QImage conversion of a Magick::Image
45std::shared_ptr<QImage>
46openshot::Magick2QImage(std::shared_ptr<Magick::Image> image)
47{
48 if (!image)
49 return nullptr;
50
51 const int BPP = 4;
52 const std::size_t size = image->columns() * image->rows() * BPP;
53
54 auto* qbuffer = new unsigned char[size]();
55
56 MagickCore::ExceptionInfo exception;
57 // TODO: Actually do something, if we get an exception here
58 MagickCore::ExportImagePixels(
59 image->constImage(), 0, 0,
60 image->columns(), image->rows(),
61 "RGBA", Magick::CharPixel,
62 qbuffer, &exception);
63
64 auto qimage = std::make_shared<QImage>(
65 qbuffer, image->columns(), image->rows(),
66 image->columns() * BPP,
67 QImage::Format_RGBA8888_Premultiplied,
68 (QImageCleanupFunction) &openshot::cleanUpBuffer,
69 (void*) qbuffer);
70 return qimage;
71}
72
73#endif // USE_IMAGEMAGICK

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected