danielalves/BlurImageProcessor
소개
BlurImageProcessor offers a very easy and practical way to generate blurred images in real time.
디자인 및 미디어측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalBlurImageProcessor
BlurImageProcessor offers a very easy and practical way to generate blurred images in real time. After an image is specified to be targeted by it, every new blur operation will create a new allocated image. Varying the value of radiuses and iterations, its possible to create many different results and even animations.
Blur operations can be synchronous and asynchronous. Synchronous operations run on the thread/operation queue from which they were called. Each ALDBlurImageProcessor object has its own processing queue to run asynchronous operations, so it it easy to manage them. Besides that, all delegate callbacks, notifications and blocks are called/fired on the same thread/operation queue from which the async blur processing operation was called. So there's no need to worry about using new blurred images directly into the user interface if you fired the operations from the main thread/operation queue.
BlurImageProcessor tries to achieve a good balance between memory and performance. It listens to UIApplicationDidReceiveMemoryWarningNotification notifications to clean temporary internal buffers on low memory conditions. In addition to that, it has an intelligent cache system: every blurredimage keeps cached while it is still living in the outside app. So, if you call another blur operation with the same radius and iterations paramneters on the same original image, no processing occurs. When the outside app stops referencing the blurred image, it is automatically removed from the cache, so there is no memory waste.
Usage
First of all, you need to instantiate a processor with a strong reference to it, passing the target image you want to blur:
#import "ALDViewController.h"
@interface MyViewController ()
{
ALDBlurImageProcessor *blurImageProcessor;
UIImageView *blurTargetImageView;
}
@end
@implementation MyViewController
-( void )viewDidLoad
{
...
blurImageProcessor = [[ALDBlurImageProcessor alloc] initWithImage: blurTargetImageView.image];
...
}
@end
Then you choose how you want to handle the generated images: via blocks, delegate or notifications.
Blocks
-( void )viewDidLoad
{
...
[blurImageProcessor asyncBlurWithRadius: 5
iterations: 7
successBlock: ^( UIImage * )blurredImage {
blurTargetImageView.image = blurredImage;
}
errorBlock: ^( NSNumber *errorCode ) {
NSLog( @"Error code: %d", [errorCode intValue] );
}];
...
}
That's all!
ALDBlurImageProcessorDelegate
Declare you are implementing ALDBlurImageProcessorDelegate:
@interface MyViewController()< ALDBlurImageProcessorDelegate >
{
ALDBlurImageProcessor *blurImageProcessor;
UIImageView *blurTargetImageView;
}
@end
Then set blurImageProcessor's delegate:
-( void )viewDidLoad
{
...
blurImageProcessor.delegate = self;
[blurImageProcessor asyncBlurWithRadius: 5 iterations: 7];
...
}
And finally implement its methods:
-( void )onALDBlurImageProcessor:( ALDBlurImageProcessor * )blurImageProcessor newBlurrredImage:( UIImage * )image
{
blurTargetImageView.image = image;
}
-( void )onALDBlurImageProcessor:( ALDBlurImageProcessor * )blurImageProcessor blurProcessingErrorCode:( NSNumber * )errorCode
{
NSLog( @"Error code: %d", [errorCode intValue] );
}
NSNotificationCenter
Using notifications, just observe the notifications you want:
-( void )viewDidLoad
{
...
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector( onNewBlurredImage: )
name: ALDBlurImageProcessorImageReadyNotification
object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector( onBlurImageProcessorError: )
name: ALDBlurImageProcessorImageProcessingErrorNotification
object: nil];
[blurImageProcessor asyncBlurWithRadius: 5 iterations: 7];
...
}
And implement the methods to handle the blurred image:
-( void )onNewBlurredImage:( NSNotification * )notification
{
UIImage *image = notification.userInfo[ ALDBlurImageProcessorImageReadyNotificationBlurrredImageKey ];
blurTargetImageView.image = image;
}
-( void )onBlurImageProcessorError:( NSNotification * )notification
{
NSNumber *errorCode = notification.userInfo[ ALDBlurImageProcessorImageProcessingErrorNotificationErrorCodeKey ];
NSLog( @"Error code: %d", [errorCode intValue] );
}
Do not forget to remove the observers you've set:
-( void )dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self
name: ALDBlurImageProcessorImageReadyNotification
object: nil];
[[NSNotificationCenter defaultCenter] removeObserver: self
name: ALDBlurImageProcessorImageProcessingErrorNotification
object: nil];
}
Requirements
iOS 6.0 or higher, ARC only
Installation
BlurImageProcessor is available through CocoaPods, to install it simply add the following line to your Podfile:
pod "BlurImageProcessor"
Author
Collaborators
License
BlurImageProcessor is available under the MIT license. See the LICENSE file for more info.
관련 프로젝트 살펴보기
불러오는 중…

