1

ほぼすべての種類の画像を PPM に変換するために、ImageMagick のワンド API を使用しています。wand から、幅、高さ、modval、生の RGB データの PPM プロパティを抽出するにはどうすればよいですか? ここにいくつかのスケルトンコードがあります。

質問を読んでくれてありがとう。

  /* 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 */
4

1 に答える 1

0

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);
于 2012-12-13T09:29:42.173 に答える