【问题标题】:ImageMagick in Iphone: how to convert Image object to UIImage in iphoneIphone 中的 ImageMagick:如何在 iphone 中将 Image 对象转换为 UIImage
【发布时间】:2011-08-05 12:35:45
【问题描述】:

我正在尝试在 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 对象,以便我可以使用该图像。

【问题讨论】:

  • @Ade:感谢您的回复。但我的困惑是我的 Image distortedImage 不在 MagickWand 中。那么如何获取新图片distortedImage???

标签: iphone imagemagick


【解决方案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];

【讨论】:

  • 在不知道大小的情况下获取 NSData 时在此处使用未声明的标识符 initWithBytes。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-10-17
  • 1970-01-01
  • 2021-08-05
  • 1970-01-01
  • 2013-06-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多