开发者

ImageMagick in Iphone: how to convert Image object to UIImage in iphone

开发者 https://www.devze.com 2023-03-25 22:24 出处:网络
I am trying to create a distortion in image using imageMagick in Iphone. Following is my code: Image *img = GetImageFromMagickWand(magick_wand);

I am trying to create a distortion in image using imageMagick in Iphone. Following is my code:

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);

Now I am开发者_开发问答 meshed over here. How to convert this distortedImage object to UIImage object so that I can use that Image.


NSData * data = [[NSData alloc] initWithBytes:distortedImage length:my_size];
free(distortedImage);
UIImage * image = [[UIImage alloc] initWithData:data];

if you don't know the size try the following:

NSData *data = UIImagePNGRepresentation(initWithBytes:distortedImage);
free(distortedImage);
UIImage * image = [[UIImage alloc] initWithData:data];
0

精彩评论

暂无评论...
验证码 换一张
取 消