YYWebImage,SDWebImage和PINRemoteImage比较

这篇博客对比了YYWebImage, SDWebImage和PINRemoteImage三个图片库的特性,包括图片后处理、格式支持、解码控制、网络请求和性能。PINRemoteImage在图片后处理和解码控制上表现更优,而YYWebImage在性能上占优势。在使用PINRemoteImage时,由于不能很好控制解码可能导致内存问题。总结指出,选择图片库应根据具体需求。" 8130993,1340813,C++ 中的 atoi() 和 itoa() 函数解析,"['C++编程', '字符串操作', '函数', '数据转换']
摘要由CSDN通过智能技术生成

YYWebImage,SDWebImage和PINRemoteImage比较

共同的特性

  1. 以类别 api 下载远程图片。
  2. 图片缓存
  3. 图片提前解码
  4. 其他

图片框架比较

图片后处理

根据下面的比较,可以看出图片后处理方面,PINRemoteImage > YYWebImage > SDWebImage

  • YYWebImage:

    • 支持不带标记的后处理。
    /**
     Set the view's `image` with a specified URL.
    
     @param imageURL    The image url (remote or local file path).
     @param placeholder he image to be set initially, until the image request finishes.
     @param options     The options to use when request the image.
     @param manager     The manager to create image request operation.
     @param progress    The block invoked (on main thread) during image request.
     @param transform   The block invoked (on background thread) to do additional image process.
     @param completion  The block invoked (on main thread) when image request completed.
     */
    - (void)yy_setImageWithURL:(nullable NSURL *)imageURL
                   placeholder:(nullable UIImage *)placeholder
                       options:(YYWebImageOptions)options
                       manager:(nullable YYWebImageManager *)manager
                      progress:(nullable YYWebImageProgressBlock)progress
                     transform:(nullable YYWebImageTransformBlock)transform
                    completion:(nullable YYWebImageCompletionBlock)completion;
  • SDWebImage: 不支持图片后处理。

  • PINRemoteImage:

    • 支持带标记的图片后处理。对于同一张图片,当需要不同的后处理方式时(a 界面需要正圆角,b 界面需要小幅度的圆角),尤为有用。

    “`
    /**
    Set placeholder on view and retrieve the image from the given URL, process it using the passed in processor block and set result on view. Call completion after image has been fetched, processed and set on view.

    @param url NSURL to fetch from.
    @param placeholderImage PINImage to set on the view while the image at URL is being retrieved.
    @param processorKey NSString key to uniquely identify processor. Used in caching.
    @param processor PINRemoteImageManagerImageProcessor processor block which should return the processed image.
    @param completion Called when url has been retrieved and set on view.
    */

  • (void)pin_setImageFromURL:(nullable NSURL )url placeholderImage:(nullable PINImage )placeholderImage processorKey:(nullable NSString *)processorKey processor:(nullable PINRemoteImageManagerImageProcessor)processor completion:(nullable PINRemoteImageManagerImageCompletion)completion;
    “`
图片格式支持

根据下面的比较,可以看出图片格式支持方面,YYWebImage = SDWebImage = PINRemoteImage

另外对于 WebP 的支持,需要下载 google 的 libwebp pod,这就需要先配置命令行代理了,才能安装此 pod,命令行代理的配置就不在此说明了。

而 YYImage 是提前先把编译 webp 的源码,并打包成了 framework,直接引入到了项目里了,避免了配置代理的繁琐工作。编译 webp 成 framework 可以参考此文

图片解码控制:

根据下面的比较,可以看出图片解码控制方面,PINRemoteImage > YYWebImage > SDWebImage

  • YYWebImage:

    • 下载完图片,会自动解码,可根据参数 YYWebImageOptionIgnoreImageDecoding 来控制不解码。

      代码位置:
      YYWebImageOperation(connectionDidFinishLoading:)
      
      BOOL shouldDecode = (self.options & YYWebImageOptionIgnoreImageDecoding) == 0;
      BOOL allowAnimation = (self.options & YYWebImageOptionIgnoreAnimatedImage) == 0;
      UIImage *image;
      BOOL hasAnimation = NO;
      if (allowAnimation) {
          image = [[YYImage alloc] initWithData:self.data scale:[UIScreen mainScreen].scale];
          if (shouldDecode) image = [image yy_imageByDecoded];
          if ([((YYImag
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值