0

我正在尝试实现在图像中内爆区域的功能。我在 iOS 应用程序中使用 MagickWand,但通过 MagickWand API,我无法指定我想要内爆的图像区域(通过 x 和 y 坐标)。内爆似乎只将半径作为参数,并且似乎使用图像的中心作为内爆操作的参考点。

目前,我正在做:

MagickImplodeImage(self->wand,-1.0);
MagickWandGenesis();
self->wand = NewMagickWand();

有没有人有这样做的经验?此外,您还有其他适用于 iOS 的图像处理库吗?

4

1 回答 1

0

ImageMagick 的几何系统需要在 implode 操作之前调用。MagickGetImageRegion将创建一个新图像进行内爆,MagickCompositeImage将应用子图像。一个示例应用程序看起来像...

include <stdlib.h>
#include <stdio.h>
#include <wand/MagickWand.h>

int main ( int argc, const char ** argv)
{
  MagickWandGenesis();
  MagickWand * wand = NULL;
  MagickWand * impl = NULL;
  wand = NewMagickWand();
  MagickReadImage(wand,"source.jpg");
  // Extract a MBR (minimum bounding rectangle) of area to implode
  impl = MagickGetImageRegion(wand, 200, 200, 200, 100);
  if ( impl ) {
    // Apply implode on sub image
    MagickImplodeImage(impl, 0.6666);
    // Place the sub-image on top of source
    MagickCompositeImage(wand, impl, OverCompositeOp, 200, 100);
  }
  MagickWriteImage(wand, "output.jpg");
  if(wand)wand = DestroyMagickWand(wand);
  if(impl)impl = DestroyMagickWand(impl);
  MagickWandTerminus();
  return 0;
}
于 2015-01-17T22:09:25.777 回答