Right Way To Export Image Object To UIImage After Resize Algorithm

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
nbyn
Posts: 1
Joined: 2015-06-07T09:26:11-07:00
Authentication code: 6789

Right Way To Export Image Object To UIImage After Resize Algorithm

Post by nbyn »

What is the right way to convert Image object into UIImage object with size property?

I am getting the size of image object via its signature property and then exporting it via NSData where my App Crashes.

Here is my code :

Code: Select all


-(UIImage *)applyAlgo {

MagickWandGenesis();
MagickWand * magick_wand = NewMagickWand();

NSData *imgData = UIImagePNGRepresentation(self.image);

MagickReadImageBlob(magick_wand, [imgData bytes], [imgData length]);

Image *image = GetImageFromMagickWand(magick_wand);

ExceptionInfo *exceptionInfo = AcquireExceptionInfo();

Image * newImage = InterpolativeResizeImage(image, image->columns, image->rows, BicubicInterpolatePixel, exceptionInfo);

size_t mySize = newImage->signature;

NSData *data = [[NSData alloc]initWithBytes:newImage length:mySize]; // App Crashes Here
free(newImage);

magick_wand = DestroyMagickWand(magick_wand);
MagickWandTerminus();

UIImage * finalImage = [[UIImage alloc] initWithData:data];

return finalImage;

}
Kindly help.
Post Reply