我试图在Iphone中使用imageMagick创建图像失真。 以下是我的代码:
Image *img = GetImageFromMagickWand(magick_wand);
const double ctrlPts[8] = {150,150,50,50,10,20,90,10};
const size_t q = 4;
ExceptionInfo *d = AcquireExceptionInfo() ;
const RectangleInfo r = {10,10,5,4};
size_t my_size;
Image *distortedImage = DistortImage(img, AffineDistortion, q, ctrlPts, MagickTrue, d);
现在我被困在这里。如何将这个distortedImage对象转换为UIImage对象,以便我可以使用该图像。
答案 0 :(得分:1)
NSData * data = [[NSData alloc] initWithBytes:distortedImage length:my_size];
free(distortedImage);
UIImage * image = [[UIImage alloc] initWithData:data];
如果您不知道尺寸,请尝试以下方法:
NSData *data = UIImagePNGRepresentation(initWithBytes:distortedImage);
free(distortedImage);
UIImage * image = [[UIImage alloc] initWithData:data];