I have a bunch of GigE network cameras that provide raw grayscale pixel data (aka mono8). I intend to use magick++ to convert this to PNG for human consumption. I'm almost sure that this should be near trivial, but I can't get it to work properly. My code so far:
Code: Select all
void png::convert(void *dest, size_t *destsize,
void *src, size_t /*srcsize*/, size_t srcwidth, size_t srcheight) {
Magick::Blob blob;
Magick::Image im(srcwidth, srcheight, "R", Magick::CharPixel, src);
im.type(Magick::GrayscaleType);
im.depth(8);
im.magick("png");
im.write(&blob);
memcpy(dest, blob.data(), blob.length());
*destsize = blob.length();
}
Any suggestions on how to proceed before I go bald? Thanks!