forked from rFlex/SCRecorder
-
Notifications
You must be signed in to change notification settings - Fork 4
/
SCImageView.h
102 lines (85 loc) · 2.73 KB
/
SCImageView.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// SCCIImageView.h
// SCRecorder
//
// Created by Simon CORSIN on 14/05/14.
// Copyright (c) 2014 rFlex. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <CoreImage/CoreImage.h>
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import "SCFilter.h"
#import "SCContext.h"
/**
A view capable of rendering CIImages.
*/
@interface SCImageView : UIView
/**
The context type to use when loading the context.
*/
@property (assign, nonatomic) SCContextType contextType;
/**
The SCContext that hold the underlying CIContext for rendering the CIImage's
Will be automatically loaded when setting the first CIImage or when rendering
for the first if using a CoreGraphics context type.
You can also set your own context.
Supported contexts are Metal, CoreGraphics, EAGL
*/
@property (strong, nonatomic) SCContext *__nullable context;
/**
The CIImage to render.
*/
@property (strong, nonatomic) CIImage *__nullable CIImage;
/**
The timestamp of the CIImage
*/
@property (assign, nonatomic) CFTimeInterval CIImageTime;
/**
The preferred transform for rendering the CIImage
*/
@property (assign, nonatomic) CGAffineTransform preferredCIImageTransform;
/**
Whether the CIImage should be scaled and resized according to the contentMode of this view.
Default is YES.
*/
@property (assign, nonatomic) BOOL scaleAndResizeCIImageAutomatically;
/**
Set the CIImage using a sampleBuffer. The CIImage will be automatically generated
when needed. This avoids creating multiple CIImage if the SCImageView can't render them
as fast.
*/
- (void)setImageBySampleBuffer:(__nonnull CMSampleBufferRef)sampleBuffer;
/**
Set the CIImage using an UIImage
*/
- (void)setImageByUIImage:(UIImage *__nullable)image;
/**
Create the CIContext and setup the underlying rendering views. This is automatically done when setting an CIImage
for the first time to make the initialization faster. If for some reasons you want it to be done earlier
you can call this method.
Returns whether the context has been successfully loaded, returns NO otherwise.
*/
- (BOOL)loadContextIfNeeded;
/**
Returns the rendered CIImage in the given rect.
Subclass can override this method to alterate the rendered image.
*/
- (CIImage *__nullable)renderedCIImageInRect:(CGRect)rect;
/**
Returns the rendered CIImage in the given rect.
It internally calls renderedCIImageInRect:
Subclass should not override this method.
*/
- (UIImage *__nullable)renderedUIImageInRect:(CGRect)rect;
/**
Returns the rendered CIImage in its natural size.
Subclass should not override this method.
*/
- (CIImage *__nullable)renderedCIImage;
/**
Returns the rendered UIImage in its natural size.
Subclass should not override this method.
*/
- (UIImage *__nullable)renderedUIImage;
@end