[英]How to extract PPM Image Properties from an ImageMagick Wand using C?
In order to convert almost any type of image into a PPM I'm using ImageMagick's wand API. 为了将几乎所有类型的图像转换成PPM,我使用了ImageMagick的wand API。 From the wand how do I extract the PPM properties of width, height, modval and raw RGB data?
如何从魔杖中提取宽度,高度,modval和原始RGB数据的PPM属性? Here is some skeleton code.
这是一些基本代码。
Many thanks in advance for reading the question. 在此先非常感谢您阅读问题。
/* Read an image. */
MagickWandGenesis();
magick_wand = NewMagickWand();
status = MagickReadImage(magick_wand, argv[1]);
if (status == MagickFalse)
ThrowWandException(magick_wand);
/* TODO convert to P6 PPM */
/* TODO get PPM properties */
ppm->width = ...
ppm->height = ...
ppm->modval = 3 * ppm->width;
ppm->data = malloc(ppm->width * ppm->height * 3);
/* TODO fill ppm->data */
From ImageMagick Forum 来自ImageMagick论坛
width = MagickGetImageWidth(magick_wand);
height = MagickGetImageHeight(magick_wand);
ppm->width = width;
ppm->height = height;
ppm->modval = 3 * width;
ppm->data = malloc (3 * width * height);
status = MagickExportImagePixels(magick_wand, 0, 0, width, height, "RGB",
CharPixel, ppm->data);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.