yaofly2012 / note

Personal blog

Home Page:https://github.com/yaofly2012/note/issues

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UIImage vs. CIImage vs. CGImage

yaofly2012 opened this issue · comments

commented

前缀:

  1. UI 表示来自UIkit
  2. Core Image
  3. CoreGraphics

UIImage, CIImage, CGImage

  1. UIImage 在APP里用于展示图片数据。
  2. CIImage 表示图片的数据,它包含创建图片的所有信息。
  3. CGImage表示位图

CIImage

CGImage

互转

CIImageCGImage

#import <CoreImage/CoreImage.h>

CIImage *ciImage = [CIImage imageWithData:data];
CIContext *ciContext = [CIContext contextWithOptions:nil];
CGImageRef cgImage = [ciContext createCGImage:ciImage fromRect:[ciImage extent]];

CGImageCIImage

CIImage提供了专门的API:

initWithCGImage

CIImage/CGImageUIImage

UIImage是顶层API,本身自带了将CIImage, CGImageUIImageAPI:

initWithCGImage:(CGImageRef)cgImage

initWithCIImage:(CIImage *)ciImage

UIImageCGImage

先把UIImage转``CIImage,再转CGImage

参考

  1. UIImage vs. CIImage vs. CGImage
  2. Bitmap Images and Image Masks
  3. (OC)* CoreImage
  4. Swift: Convert between CGImage, CIImage and UIImage
  5. Core Image Tutorial: Getting Started