开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜