This commit is contained in:
启星
2025-11-06 13:04:04 +08:00
parent 4aa2fac912
commit 406c481ba4
105 changed files with 1449 additions and 251 deletions

View File

@@ -31,7 +31,13 @@ typedef NS_ENUM(NSUInteger, GradientType) {
+ (UIImage *)qx_convertViewToImageWith:(UIView *)view;
+ (UIImage *)qx_gradientColorImageFromColors:(NSArray*)colors gradientType:(GradientType)gradientType imgSize:(CGSize)imgSize;
/**
传入一张图片将图片改为灰色
@param inputImage 传入图片
@return 生成的UIImage
*/
+ (UIImage *)qx_convertImageToGrayWithCoreImage:(UIImage *)inputImage;
/**
根据颜色生成UIImage对象

View File

@@ -42,7 +42,24 @@
return image;
}
+ (UIImage *)qx_convertImageToGrayWithCoreImage:(UIImage *)inputImage {
CIImage *ciImage = [[CIImage alloc] initWithImage:inputImage];
// 使
CIFilter *grayFilter = [CIFilter filterWithName:@"CIColorControls"];
[grayFilter setValue:ciImage forKey:kCIInputImageKey];
[grayFilter setValue:@(0.0) forKey:kCIInputSaturationKey]; // 0
CIImage *outputImage = [grayFilter valueForKey:kCIOutputImageKey];
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef cgImage = [context createCGImage:outputImage fromRect:[outputImage extent]];
UIImage *grayImage = [UIImage imageWithCGImage:cgImage];
CGImageRelease(cgImage);
return grayImage;
}
+ (UIImage *)qx_gradientColorImageFromColors:(NSArray *)colors gradientType:(GradientType)gradientType imgSize:(CGSize)imgSize {
NSMutableArray *ar = [NSMutableArray array];
for (UIColor *c in colors) {