Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIImage vs. CIImage vs. CGImage #275

Open
yaofly2012 opened this issue May 23, 2023 · 0 comments
Open

UIImage vs. CIImage vs. CGImage #275

yaofly2012 opened this issue May 23, 2023 · 0 comments

Comments

@yaofly2012
Copy link
Owner

yaofly2012 commented May 23, 2023

前缀:

  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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant