简体   繁体   English

使用Magick ++解码PNG图像

[英]Decode PNG image with Magick++

I need to put decoded RGBA data (from 32-bit PNG) in cl::Image2D, then (after some processing) write it back to Magick++ image with enqueueReadImage(). 我需要将解码后的RGBA数据(来自32位PNG)放在cl :: Image2D中,然后(经过一些处理后)用enqueueReadImage()将其写回Magick ++图像。

However, at the moment I do not see any way to access RGBA data directly in Magick++ image object. 但是,目前我还没有看到任何方法直接在Magick ++图像对象中访问RGBA数据。 Is this possible? 这可能吗? If not, what's the best way to get data in RGBA format from Magick++ object? 如果没有,从Magick ++对象获取RGBA格式数据的最佳方法是什么?

You can use the Magick::Image::write function 您可以使用Magick :: Image :: write函数

Magick::Image im;
// read image ....

// only for RGBA !!!
size_t im_size = im.columns() * im.rows() * 4;
uint8_t * pixels = new uint8_t[im_size];
im.write(0, 0, im.columns(), im.rows(), "RGBA", ::Magick::CharPixel, pixels);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM