Domanda

I am trying to implement the functionality of imploding a region within an image. I am using MagickWand within the iOS application, but through MagickWand API I am not able to specify the region of the image (through x and y coordinates) that I would like to implode. Implode seems to be taking only radius as parameter and seems to be using the center of the image as reference point for implode operation.

Currently, I am doing:

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

Does anyone have any experience doing this? Also, are there any other image processing libraries that you'd recommend for iOS?

È stato utile?

Soluzione

ImageMagick's Geometry system will need to invoked before implode operation. MagickGetImageRegion will create a new image to implode, and MagickCompositeImage would apply the sub-image back. An example application would look like...

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;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top