【问题标题】:How to get c buffer from ImageMagick Image如何从 ImageMagick Image 获取 c 缓冲区
【发布时间】:2011-03-16 13:37:31
【问题描述】:

我正在使用 ImageMagick 的 iPhone 端口。我正在尝试遍历动画 gif 的帧并将每个帧转换为 UIImage。我知道我可以用 NSData 初始化 UIImage,我可以用 const void * 初始化。那么如何获取图片的缓冲区和长度呢?

代码如下:

    MagickReadImage(wand, filename);

        while(MagickHasNextImage(wand)) {
             Image *myImage = GetImageFromMagickWand(wand);
             //HELP ME PLEASE
             const void *myBuff =myImage->blob;  //guessing this is the right way to get the buffer?
             int myLength = ????? //no idea how to get the length
             NSData *myData = [[NSData alloc] initWithBytes:myBuff length:myLength];
             UIImage myImage = [[UIImage alloc] initWithData:myData]];
             MagickNextImage(wand);
    }

【问题讨论】:

    标签: c++ objective-c imagemagick


    【解决方案1】:

    我现在有了解决方案:

        size_t my_size;
        unsigned char * my_image = MagickGetImageBlob(wand, &my_size);
        NSData * data = [[NSData alloc] initWithBytes:my_image length:my_size];
        free(my_image);
    
        UIImage * image = [[UIImage alloc] initWithData:data];
    

    【讨论】:

      猜你喜欢
      • 2013-06-11
      • 2013-06-24
      • 1970-01-01
      • 1970-01-01
      • 2015-09-06
      • 2012-03-15
      • 1970-01-01
      • 2011-05-28
      • 1970-01-01
      相关资源
      最近更新 更多