Commit 0782c6e7301e5277e83e71dccc9c84ede5a1cdd2
1 parent
bb25bc8c
添加图片分类,模糊图片
Showing
4 changed files
with
95 additions
and
29 deletions
LiveVideoCloud/LiveVideoCloud.xcodeproj/project.pbxproj
| @@ -161,6 +161,8 @@ | @@ -161,6 +161,8 @@ | ||
| 161 | D25BF89B1E7FE046007FB138 /* CNLiveChatManager.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D25BF8981E7FE033007FB138 /* CNLiveChatManager.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; | 161 | D25BF89B1E7FE046007FB138 /* CNLiveChatManager.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D25BF8981E7FE033007FB138 /* CNLiveChatManager.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; |
| 162 | D25BF89C1E7FE049007FB138 /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D25BF8961E7FE01B007FB138 /* CNLiveMsgTools.framework */; }; | 162 | D25BF89C1E7FE049007FB138 /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D25BF8961E7FE01B007FB138 /* CNLiveMsgTools.framework */; }; |
| 163 | D25BF89D1E7FE049007FB138 /* CNLiveMsgTools.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D25BF8961E7FE01B007FB138 /* CNLiveMsgTools.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; | 163 | D25BF89D1E7FE049007FB138 /* CNLiveMsgTools.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D25BF8961E7FE01B007FB138 /* CNLiveMsgTools.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; |
| 164 | + D25BF8A01E80C4BD007FB138 /* UIImage+LVCVagueImage.m in Sources */ = {isa = PBXBuildFile; fileRef = D25BF89F1E80C4BD007FB138 /* UIImage+LVCVagueImage.m */; }; | ||
| 165 | + D25BF8A31E80C4FC007FB138 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D25BF8A21E80C4FC007FB138 /* Accelerate.framework */; }; | ||
| 164 | D2888D941E6EB8B4003A77C8 /* LVCTabBar.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888D931E6EB8B4003A77C8 /* LVCTabBar.m */; }; | 166 | D2888D941E6EB8B4003A77C8 /* LVCTabBar.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888D931E6EB8B4003A77C8 /* LVCTabBar.m */; }; |
| 165 | D2888D9E1E6EBF1B003A77C8 /* LVCLiveViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888D9B1E6EBF1B003A77C8 /* LVCLiveViewController.m */; }; | 167 | D2888D9E1E6EBF1B003A77C8 /* LVCLiveViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888D9B1E6EBF1B003A77C8 /* LVCLiveViewController.m */; }; |
| 166 | D2888DB11E6EC05F003A77C8 /* TempViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB01E6EC05F003A77C8 /* TempViewController.m */; }; | 168 | D2888DB11E6EC05F003A77C8 /* TempViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB01E6EC05F003A77C8 /* TempViewController.m */; }; |
| @@ -515,6 +517,9 @@ | @@ -515,6 +517,9 @@ | ||
| 515 | D25BF8921E7FBAEA007FB138 /* LVCUGCBackgroundView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCBackgroundView.m; sourceTree = "<group>"; }; | 517 | D25BF8921E7FBAEA007FB138 /* LVCUGCBackgroundView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCBackgroundView.m; sourceTree = "<group>"; }; |
| 516 | D25BF8961E7FE01B007FB138 /* CNLiveMsgTools.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveMsgTools.framework; sourceTree = "<group>"; }; | 518 | D25BF8961E7FE01B007FB138 /* CNLiveMsgTools.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveMsgTools.framework; sourceTree = "<group>"; }; |
| 517 | D25BF8981E7FE033007FB138 /* CNLiveChatManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveChatManager.framework; sourceTree = "<group>"; }; | 519 | D25BF8981E7FE033007FB138 /* CNLiveChatManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveChatManager.framework; sourceTree = "<group>"; }; |
| 520 | + D25BF89E1E80C4BD007FB138 /* UIImage+LVCVagueImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+LVCVagueImage.h"; sourceTree = "<group>"; }; | ||
| 521 | + D25BF89F1E80C4BD007FB138 /* UIImage+LVCVagueImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+LVCVagueImage.m"; sourceTree = "<group>"; }; | ||
| 522 | + D25BF8A21E80C4FC007FB138 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; }; | ||
| 518 | D2888D921E6EB8B4003A77C8 /* LVCTabBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCTabBar.h; sourceTree = "<group>"; }; | 523 | D2888D921E6EB8B4003A77C8 /* LVCTabBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCTabBar.h; sourceTree = "<group>"; }; |
| 519 | D2888D931E6EB8B4003A77C8 /* LVCTabBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCTabBar.m; sourceTree = "<group>"; }; | 524 | D2888D931E6EB8B4003A77C8 /* LVCTabBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCTabBar.m; sourceTree = "<group>"; }; |
| 520 | D2888D9A1E6EBF1B003A77C8 /* LVCLiveViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCLiveViewController.h; sourceTree = "<group>"; }; | 525 | D2888D9A1E6EBF1B003A77C8 /* LVCLiveViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCLiveViewController.h; sourceTree = "<group>"; }; |
| @@ -532,6 +537,7 @@ | @@ -532,6 +537,7 @@ | ||
| 532 | isa = PBXFrameworksBuildPhase; | 537 | isa = PBXFrameworksBuildPhase; |
| 533 | buildActionMask = 2147483647; | 538 | buildActionMask = 2147483647; |
| 534 | files = ( | 539 | files = ( |
| 540 | + D25BF8A31E80C4FC007FB138 /* Accelerate.framework in Frameworks */, | ||
| 535 | D2575C7D1E76A4F300E3A8FC /* NHGiftAnimtionSDK.a in Frameworks */, | 541 | D2575C7D1E76A4F300E3A8FC /* NHGiftAnimtionSDK.a in Frameworks */, |
| 536 | 812E50531E7699DC004F5FCD /* CNLivePlayerSDK.framework in Frameworks */, | 542 | 812E50531E7699DC004F5FCD /* CNLivePlayerSDK.framework in Frameworks */, |
| 537 | D25BF89A1E7FE046007FB138 /* CNLiveChatManager.framework in Frameworks */, | 543 | D25BF89A1E7FE046007FB138 /* CNLiveChatManager.framework in Frameworks */, |
| @@ -625,6 +631,7 @@ | @@ -625,6 +631,7 @@ | ||
| 625 | D2029B9D1E6EAAA50027CD92 /* LiveVideoCloudTests */, | 631 | D2029B9D1E6EAAA50027CD92 /* LiveVideoCloudTests */, |
| 626 | D2029BA81E6EAAA50027CD92 /* LiveVideoCloudUITests */, | 632 | D2029BA81E6EAAA50027CD92 /* LiveVideoCloudUITests */, |
| 627 | D2029B821E6EAAA50027CD92 /* Products */, | 633 | D2029B821E6EAAA50027CD92 /* Products */, |
| 634 | + D25BF8A11E80C4FC007FB138 /* Frameworks */, | ||
| 628 | ); | 635 | ); |
| 629 | sourceTree = "<group>"; | 636 | sourceTree = "<group>"; |
| 630 | }; | 637 | }; |
| @@ -1131,6 +1138,8 @@ | @@ -1131,6 +1138,8 @@ | ||
| 1131 | D2029CE91E6EAE2E0027CD92 /* UILabel+labelFitSize.m */, | 1138 | D2029CE91E6EAE2E0027CD92 /* UILabel+labelFitSize.m */, |
| 1132 | D2029CEA1E6EAE2E0027CD92 /* UIView+Extension.h */, | 1139 | D2029CEA1E6EAE2E0027CD92 /* UIView+Extension.h */, |
| 1133 | D2029CEB1E6EAE2E0027CD92 /* UIView+Extension.m */, | 1140 | D2029CEB1E6EAE2E0027CD92 /* UIView+Extension.m */, |
| 1141 | + D25BF89E1E80C4BD007FB138 /* UIImage+LVCVagueImage.h */, | ||
| 1142 | + D25BF89F1E80C4BD007FB138 /* UIImage+LVCVagueImage.m */, | ||
| 1134 | ); | 1143 | ); |
| 1135 | path = Category; | 1144 | path = Category; |
| 1136 | sourceTree = "<group>"; | 1145 | sourceTree = "<group>"; |
| @@ -1406,6 +1415,14 @@ | @@ -1406,6 +1415,14 @@ | ||
| 1406 | path = Videos; | 1415 | path = Videos; |
| 1407 | sourceTree = "<group>"; | 1416 | sourceTree = "<group>"; |
| 1408 | }; | 1417 | }; |
| 1418 | + D25BF8A11E80C4FC007FB138 /* Frameworks */ = { | ||
| 1419 | + isa = PBXGroup; | ||
| 1420 | + children = ( | ||
| 1421 | + D25BF8A21E80C4FC007FB138 /* Accelerate.framework */, | ||
| 1422 | + ); | ||
| 1423 | + name = Frameworks; | ||
| 1424 | + sourceTree = "<group>"; | ||
| 1425 | + }; | ||
| 1409 | D2888D911E6EB897003A77C8 /* View */ = { | 1426 | D2888D911E6EB897003A77C8 /* View */ = { |
| 1410 | isa = PBXGroup; | 1427 | isa = PBXGroup; |
| 1411 | children = ( | 1428 | children = ( |
| @@ -1744,6 +1761,7 @@ | @@ -1744,6 +1761,7 @@ | ||
| 1744 | D2029B861E6EAAA50027CD92 /* main.m in Sources */, | 1761 | D2029B861E6EAAA50027CD92 /* main.m in Sources */, |
| 1745 | D2029C8C1E6EADE10027CD92 /* AFURLSessionManager.m in Sources */, | 1762 | D2029C8C1E6EADE10027CD92 /* AFURLSessionManager.m in Sources */, |
| 1746 | D2029C9F1E6EADE10027CD92 /* NSObject+MJKeyValue.m in Sources */, | 1763 | D2029C9F1E6EADE10027CD92 /* NSObject+MJKeyValue.m in Sources */, |
| 1764 | + D25BF8A01E80C4BD007FB138 /* UIImage+LVCVagueImage.m in Sources */, | ||
| 1747 | D2888DB11E6EC05F003A77C8 /* TempViewController.m in Sources */, | 1765 | D2888DB11E6EC05F003A77C8 /* TempViewController.m in Sources */, |
| 1748 | 810B65021E779B1F00133E15 /* MASViewAttribute.m in Sources */, | 1766 | 810B65021E779B1F00133E15 /* MASViewAttribute.m in Sources */, |
| 1749 | D2029CAC1E6EADE10027CD92 /* MJRefreshBackStateFooter.m in Sources */, | 1767 | D2029CAC1E6EADE10027CD92 /* MJRefreshBackStateFooter.m in Sources */, |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCPlayerLoadingView.m
| @@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
| 7 | // | 7 | // |
| 8 | 8 | ||
| 9 | #import "LVCUGCPlayerLoadingView.h" | 9 | #import "LVCUGCPlayerLoadingView.h" |
| 10 | +#import "UIImage+LVCVagueImage.h" | ||
| 10 | 11 | ||
| 11 | @interface LVCUGCPlayerLoadingView() { | 12 | @interface LVCUGCPlayerLoadingView() { |
| 12 | 13 | ||
| @@ -32,38 +33,13 @@ | @@ -32,38 +33,13 @@ | ||
| 32 | - (UIImageView *)bgImageView { | 33 | - (UIImageView *)bgImageView { |
| 33 | if (!_bgImageView) { | 34 | if (!_bgImageView) { |
| 34 | 35 | ||
| 35 | - // 1、创建输入图像,CIImage类型,这里使用一个网上图片。 | ||
| 36 | - CIImage *inputImage = [CIImage imageWithContentsOfURL:[NSURL URLWithString:@"http://echo-image.qiniucdn.com/FtPAdyCH-SlO-5xEe009AFE-N0EF?imageMogr2/auto-orient/quality/100%7CimageView2/4/w/640/q/100"]]; | ||
| 37 | - | ||
| 38 | - // 2、构建一个滤镜图表 | ||
| 39 | - CIColor *sepiaColor = [CIColor colorWithRed:0.76 green:0.65 blue:0.54]; | ||
| 40 | - // 2.1 先构建一个 CIColorMonochrome 滤镜,并配置输入图像与滤镜参数 | ||
| 41 | - CIFilter *monochromeFilter = [CIFilter filterWithName:@"CIColorMonochrome" withInputParameters:@{@"inputColor" : sepiaColor,@"inputIntensity":@1.0}]; | ||
| 42 | - [monochromeFilter setValue:inputImage forKey:@"inputImage"];// 通过KVC来设置输入图像 | ||
| 43 | - // 2.2 先构建一个 CIVignette 滤镜 | ||
| 44 | - CIFilter *vignetteFilter = [CIFilter filterWithName:@"CIVignette" withInputParameters:@{@"inputRadius" : @2.0,@"inputIntensity" :@1.0}]; | ||
| 45 | - [vignetteFilter setValue:monochromeFilter.outputImage forKey:@"inputImage"];// 以monochromeFilter的输出来作为输入 | ||
| 46 | - | ||
| 47 | - // 3、得到一个滤镜处理后的图片,并转换至 UIImage | ||
| 48 | - // 创建一个 CIContext | ||
| 49 | - CIContext *ciContext = [CIContext contextWithOptions:nil]; | ||
| 50 | - // 将 CIImage 过渡到 CGImageRef 类型 | ||
| 51 | - CGImageRef cgImage = [ciContext createCGImage:vignetteFilter.outputImage fromRect:inputImage.extent]; | ||
| 52 | - // 最后转换为 UIImage 类型 | ||
| 53 | - UIImage *uiImage = [UIImage imageWithCGImage:cgImage]; | ||
| 54 | - | ||
| 55 | -// NSString *path = [[NSBundle mainBundle] pathForResource:@"UGCLoading" ofType:@"jpeg"]; | ||
| 56 | -// UIImage *image = [UIImage imageWithContentsOfFile:path]; | ||
| 57 | - _bgImageView = [[UIImageView alloc] initWithImage:uiImage]; | 36 | + NSString *path = [[NSBundle mainBundle] pathForResource:@"UGCLoading" ofType:@"jpeg"]; |
| 37 | + UIImage *image = [UIImage imageWithContentsOfFile:path]; | ||
| 38 | + UIImage *blurImage = [UIImage boxblurImage:image withBlurNumber:0.6]; | ||
| 39 | + _bgImageView = [[UIImageView alloc] initWithImage:blurImage]; | ||
| 58 | _bgImageView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); | 40 | _bgImageView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); |
| 59 | - _bgImageView.backgroundColor = [UIColor whiteColor]; | ||
| 60 | _bgImageView.contentMode = UIViewContentModeScaleAspectFill; | 41 | _bgImageView.contentMode = UIViewContentModeScaleAspectFill; |
| 61 | _bgImageView.clipsToBounds = YES; | 42 | _bgImageView.clipsToBounds = YES; |
| 62 | -// UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; | ||
| 63 | -// UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; | ||
| 64 | -// effectView.frame = _bgImageView.bounds; | ||
| 65 | -// [_bgImageView addSubview:effectView]; | ||
| 66 | -// effectView.alpha = .8f; | ||
| 67 | } | 43 | } |
| 68 | return _bgImageView; | 44 | return _bgImageView; |
| 69 | } | 45 | } |
LiveVideoCloud/LiveVideoCloud/UtilKits/Category/UIImage+LVCVagueImage.h
0 → 100644
| 1 | +// | ||
| 2 | +// UIImage+LVCVagueImage.h | ||
| 3 | +// LiveVideoCloud | ||
| 4 | +// | ||
| 5 | +// Created by cnliveJunBo on 17/3/21. | ||
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <UIKit/UIKit.h> | ||
| 10 | + | ||
| 11 | +@interface UIImage (LVCVagueImage) | ||
| 12 | + | ||
| 13 | ++ (UIImage *)boxblurImage:(UIImage *)image withBlurNumber:(CGFloat)blur; | ||
| 14 | + | ||
| 15 | +@end |
LiveVideoCloud/LiveVideoCloud/UtilKits/Category/UIImage+LVCVagueImage.m
0 → 100644
| 1 | +// | ||
| 2 | +// UIImage+LVCVagueImage.m | ||
| 3 | +// LiveVideoCloud | ||
| 4 | +// | ||
| 5 | +// Created by cnliveJunBo on 17/3/21. | ||
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "UIImage+LVCVagueImage.h" | ||
| 10 | +#import <Accelerate/Accelerate.h> | ||
| 11 | + | ||
| 12 | +@implementation UIImage (LVCVagueImage) | ||
| 13 | + | ||
| 14 | ++ (UIImage *)boxblurImage:(UIImage *)image withBlurNumber:(CGFloat)blur | ||
| 15 | +{ | ||
| 16 | + if (blur < 0.f || blur > 1.f) { | ||
| 17 | + blur = 0.5f; | ||
| 18 | + } | ||
| 19 | + int boxSize = (int)(blur * 40); | ||
| 20 | + boxSize = boxSize - (boxSize % 2) + 1; | ||
| 21 | + CGImageRef img = image.CGImage; | ||
| 22 | + vImage_Buffer inBuffer, outBuffer; | ||
| 23 | + vImage_Error error; | ||
| 24 | + void *pixelBuffer; | ||
| 25 | + //从CGImage中获取数据 | ||
| 26 | + CGDataProviderRef inProvider = CGImageGetDataProvider(img); | ||
| 27 | + CFDataRef inBitmapData = CGDataProviderCopyData(inProvider); | ||
| 28 | + //设置从CGImage获取对象的属性 | ||
| 29 | + inBuffer.width = CGImageGetWidth(img); | ||
| 30 | + inBuffer.height = CGImageGetHeight(img); | ||
| 31 | + inBuffer.rowBytes = CGImageGetBytesPerRow(img); | ||
| 32 | + inBuffer.data = (void*)CFDataGetBytePtr(inBitmapData); | ||
| 33 | + pixelBuffer = malloc(CGImageGetBytesPerRow(img) * CGImageGetHeight(img)); | ||
| 34 | + if(pixelBuffer == NULL) | ||
| 35 | + NSLog(@"No pixelbuffer"); | ||
| 36 | + outBuffer.data = pixelBuffer; | ||
| 37 | + outBuffer.width = CGImageGetWidth(img); | ||
| 38 | + outBuffer.height = CGImageGetHeight(img); | ||
| 39 | + outBuffer.rowBytes = CGImageGetBytesPerRow(img); | ||
| 40 | + error = vImageBoxConvolve_ARGB8888(&inBuffer, &outBuffer, NULL, 0, 0, boxSize, boxSize, NULL, kvImageEdgeExtend); | ||
| 41 | + if (error) { | ||
| 42 | + NSLog(@"error from convolution %ld", error); | ||
| 43 | + } | ||
| 44 | + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); | ||
| 45 | + CGContextRef ctx = CGBitmapContextCreate( outBuffer.data, outBuffer.width, outBuffer.height, 8, outBuffer.rowBytes, colorSpace, kCGImageAlphaNoneSkipLast); | ||
| 46 | + CGImageRef imageRef = CGBitmapContextCreateImage (ctx); | ||
| 47 | + UIImage *returnImage = [UIImage imageWithCGImage:imageRef]; | ||
| 48 | + //clean up CGContextRelease(ctx); | ||
| 49 | + CGColorSpaceRelease(colorSpace); | ||
| 50 | + free(pixelBuffer); | ||
| 51 | + CFRelease(inBitmapData); | ||
| 52 | + CGColorSpaceRelease(colorSpace); | ||
| 53 | + CGImageRelease(imageRef); | ||
| 54 | + return returnImage; | ||
| 55 | +} | ||
| 56 | + | ||
| 57 | +@end |