-
Notifications
You must be signed in to change notification settings - Fork 0
/
CoreImage.framework.h
4845 lines (3940 loc) · 206 KB
/
CoreImage.framework.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ========== CoreImage.framework/Headers/CIContext.h
/* CoreImage - CIContext.h
Copyright (c) 2014 Apple, Inc.
All rights reserved. */
#import <CoreImage/CIImage.h>
#import <CoreImage/CoreImageDefines.h>
#import <CoreVideo/CoreVideo.h>
#if TARGET_OS_IPHONE && (TARGET_OS_EMBEDDED || TARGET_OS_SIMULATOR || !TARGET_OS_UIKITFORMAC)
#import <OpenGLES/EAGL.h>
#elif TARGET_OS_OSX
#import <OpenGL/CGLTypes.h>
#endif
@class CIFilter;
@protocol MTLDevice, MTLTexture, MTLCommandBuffer;
NS_ASSUME_NONNULL_BEGIN
NS_CLASS_AVAILABLE(10_4, 5_0)
@interface CIContext : NSObject
{
void *_priv;
}
/* Keys that may be passed in the dictionary while creating contexts: */
typedef NSString * CIContextOption NS_TYPED_ENUM;
/* A CGColorSpaceRef object defining the color space that images are
* converted to before rendering into the context. */
CORE_IMAGE_EXPORT CIContextOption const kCIContextOutputColorSpace;
/* A CGColorSpaceRef object defining the color space in which all
* intermediate operations are performed. */
CORE_IMAGE_EXPORT CIContextOption const kCIContextWorkingColorSpace;
/* An NSNumber with a CIFormat value defining the pixel format to use for intermediate buffers.
* On iOS the supported values for this key are RGBA8 and RGBAh. If not specified:
* RGBA8 is used if app is linked against OSX 10.12 SDK or earlier.
* RGBAh is used if app is linked against OSX 10.13 SDK or later.
* On OSX the supported values for this key are RGBA8, RGBAh and RGBAf. If not specified, RGBAh is used. */
CORE_IMAGE_EXPORT CIContextOption const kCIContextWorkingFormat NS_AVAILABLE(10_4,8_0);
/* A boolean NSNumber controlling the quality of affine downsample operations.
* @YES implies that more quality is desired.
* On iOS the default value is @NO.
* On OSX the default value is @YES. */
CORE_IMAGE_EXPORT CIContextOption const kCIContextHighQualityDownsample NS_AVAILABLE(10_11,9_0);
/* A boolean NSNumber controlling whether output renders produce alpha-premultiplied pixels.
* The default value is @YES. */
CORE_IMAGE_EXPORT CIContextOption const kCIContextOutputPremultiplied NS_AVAILABLE(10_4,7_0);
/* A boolean NSNumber controlling how intermediate buffers are cached.
* If @NO, the context will empty intermediates during and after renders.
* The default value is @YES. */
CORE_IMAGE_EXPORT CIContextOption const kCIContextCacheIntermediates NS_AVAILABLE(10_12,10_0);
/* An NSNumber with a boolean value. When @YES the context will use
* software rendering on macOS. */
CORE_IMAGE_EXPORT CIContextOption const kCIContextUseSoftwareRenderer;
/* An NSNumber with a boolean value. When @YES the context will use
* low priority rendering on the GPU. */
CORE_IMAGE_EXPORT CIContextOption const kCIContextPriorityRequestLow NS_AVAILABLE(10_12, 8_0);
/* A boolean value specifying whether or not to allow use of low-power devices for GPU rendering.
* If @YES, the context will use a low power GPU if available and the high power device is not already in use.
* The default value is @NO which instructs the context to use the highest power/performance device. */
CORE_IMAGE_EXPORT CIContextOption const kCIContextAllowLowPower NS_AVAILABLE(10_12, 13_0);
#pragma mark - contextWithCGLContext
/* Create a new CoreImage context object, all output will be drawn
* into the surface attached to the OpenGL context 'cglctx'. If 'pixelFormat' is
* non-null it should be the pixel format object used to create 'cglctx';
* it's required to be valid for the lifetime of the CIContext.
* The colorspace should be set to the colorspace of your target otherwise
* CI will take the colorspace from the CGLContext if available. */
#if TARGET_OS_OSX
+ (CIContext *)contextWithCGLContext:(CGLContextObj)cglctx
pixelFormat:(nullable CGLPixelFormatObj)pixelFormat
colorSpace:(nullable CGColorSpaceRef)colorSpace
options:(nullable NSDictionary<CIContextOption, id> *)options
CI_GL_DEPRECATED_MAC(10_6,10_14);
#endif
/* DEPRECATED, please use the method above or if you need this
* for backward capability, make sure that you specify the colorspace
* in the options dictionary */
#if TARGET_OS_OSX
+ (CIContext *)contextWithCGLContext:(CGLContextObj)cglctx
pixelFormat:(nullable CGLPixelFormatObj)pixelFormat
options:(nullable NSDictionary<CIContextOption, id> *)options
CI_GL_DEPRECATED_MAC(10_4,10_6);
#endif
#pragma mark - contextWithCGContext
/* Create a context specifying a destination CGContext.
*
* Core Image will use an internal destination context when methods such
* as [context render:to...] or [context createCGImage:...] are called.
*
* The [context drawImage:...] render methods will render to the CGContext.
*/
+ (CIContext *)contextWithCGContext:(CGContextRef)cgctx
options:(nullable NSDictionary<CIContextOption, id> *)options
NS_AVAILABLE(10_4,9_0);
#pragma mark - context without specifying a destination
/* Create a context without specifying a destination CG/GL/Metal context.
*
* Core Image will use an internal destination context when methods such
* as [context render:to...] or [context createCGImage:...] are called.
*
* The [context drawImage:...] render methods will not operate on this type
* of context.
*/
+ (CIContext *)contextWithOptions:(nullable NSDictionary<CIContextOption, id> *)options
NS_AVAILABLE(10_4,5_0);
+ (CIContext *)context NS_AVAILABLE(10_4,5_0);
- (instancetype)initWithOptions:(nullable NSDictionary<CIContextOption, id> *)options
NS_AVAILABLE(10_4,5_0);
- (instancetype)init NS_AVAILABLE(10_4,5_0);
#pragma mark - contextWithEAGLContext
/* Create a context specifying a destination EAGLContext.
*
* Core Image will use an internal destination context when methods such
* as [context render:to...] or [context createCGImage:...] are called.
*
* The [context drawImage:...] render methods will render to the EAGLContext.
*/
#if TARGET_OS_IPHONE && (TARGET_OS_EMBEDDED || TARGET_OS_SIMULATOR || !TARGET_OS_UIKITFORMAC)
+ (CIContext *)contextWithEAGLContext:(EAGLContext *)eaglContext
CI_GL_DEPRECATED_IOS(5_0,12_0);
+ (CIContext *)contextWithEAGLContext:(EAGLContext *)eaglContext
options:(nullable NSDictionary<CIContextOption, id> *)options
CI_GL_DEPRECATED_IOS(5_0,12_0);
#endif
#pragma mark - contextWithMTLDevice
/* If a system has more than one MTLDevice, then you can create a CIContext
* that uses a specific device. If a client wishes to use the default MTLDevice
* then call [CIContext contextWithOptions:] instead. */
+ (CIContext *)contextWithMTLDevice:(id<MTLDevice>)device NS_AVAILABLE(10_11,9_0);
+ (CIContext *)contextWithMTLDevice:(id<MTLDevice>)device
options:(nullable NSDictionary<CIContextOption, id> *)options
NS_AVAILABLE(10_11,9_0);
#pragma mark - properties
// The working color space of the CIContext
// The property will be null if the context was created with color management disabled.
@property (nullable, nonatomic, readonly) CGColorSpaceRef workingColorSpace NS_AVAILABLE(10_11,9_0);
// The working pixel format of the CIContext used for intermediate buffers
@property (nonatomic, readonly) CIFormat workingFormat NS_AVAILABLE(10_11,9_0);
#pragma mark - render methods
/* DEPRECATED, please use drawImage:inRect:fromRect: instead.
* Render the subregion 'fromRect' of 'image' to point 'atPoint' in the context's destination. */
- (void)drawImage:(CIImage *)image
atPoint:(CGPoint)atPoint
fromRect:(CGRect)fromRect NS_DEPRECATED(10_4,10_8, 5_0,6_0);
/* Render the rectangle 'fromRect' of 'image' to the rectangle 'inRect' in the
* context's destination. */
- (void)drawImage:(CIImage *)image
inRect:(CGRect)inRect
fromRect:(CGRect)fromRect;
/* Create a CoreGraphics layer object suitable for creating content for
* subsequently rendering into this CI context. The 'info' parameter is
* passed into CGLayerCreate () as the auxiliaryInfo dictionary.
* This will return null if size is empty or infinite. */
- (nullable CGLayerRef)createCGLayerWithSize:(CGSize)size
info:(nullable CFDictionaryRef)info
CF_RETURNS_RETAINED NS_DEPRECATED_MAC(10_4,10_11);
/* Render 'image' to the given bitmap.
* The 'data' parameter must point to at least rowBytes*floor(bounds.size.height) bytes.
* The 'bounds' parameter has the following behavior:
* The 'bounds' parameter acts to specify the region of 'image' to render.
* This region (regardless of its origin) is rendered at upper-left corner of 'data'.
* Passing a 'colorSpace' value of null means:
* Disable output color management if app is linked against iOS SDK
* Disable output color management if app is linked against OSX 10.11 SDK or later
* Match to context's output color space if app is linked against OSX 10.10 SDK or earlier
*/
- (void)render:(CIImage *)image
toBitmap:(void *)data
rowBytes:(ptrdiff_t)rowBytes
bounds:(CGRect)bounds
format:(CIFormat)format
colorSpace:(nullable CGColorSpaceRef)colorSpace;
#if COREIMAGE_SUPPORTS_IOSURFACE
/* Render 'image' to the given IOSurface.
* The 'bounds' parameter has the following behavior:
* The 'image' is rendered into 'surface' so that
* point (0,0) of 'image' aligns to the lower left corner of 'surface'.
* The 'bounds' acts like a clip rect to limit what region of 'surface' is modified.
*/
- (void)render:(CIImage *)image
toIOSurface:(IOSurfaceRef)surface
bounds:(CGRect)bounds
colorSpace:(nullable CGColorSpaceRef)colorSpace NS_AVAILABLE(10_6,5_0);
#endif
/* Render 'image' into the given CVPixelBuffer.
* In OS X 10.11.3 and iOS 9.3 and later
* CI will color match to the colorspace of the buffer.
* otherwise
* CI will color match to the context's output colorspace.
*/
- (void)render:(CIImage *)image
toCVPixelBuffer:(CVPixelBufferRef)buffer NS_AVAILABLE(10_11,5_0);
/* Render 'image' to the given CVPixelBufferRef.
* The 'bounds' parameter has the following behavior:
* In OS X and iOS 9 and later: The 'image' is rendered into 'buffer' so that
* point (0,0) of 'image' aligns to the lower left corner of 'buffer'.
* The 'bounds' acts like a clip rect to limit what region of 'buffer' is modified.
* In iOS 8 and earlier: The 'bounds' parameter acts to specify the region of 'image' to render.
* This region (regardless of its origin) is rendered at upper-left corner of 'buffer'.
* If 'colorSpace' is nil, CI will not color match to the destination.
*/
- (void)render:(CIImage *)image
toCVPixelBuffer:(CVPixelBufferRef)buffer
bounds:(CGRect)bounds
colorSpace:(nullable CGColorSpaceRef)colorSpace NS_AVAILABLE(10_11,5_0);
/* Render 'bounds' of 'image' to a Metal texture, optionally specifying what command buffer to use.
* Texture type must be MTLTexture2D.
*/
- (void)render:(CIImage *)image
toMTLTexture:(id<MTLTexture>)texture
commandBuffer:(nullable id<MTLCommandBuffer>)commandBuffer
bounds:(CGRect)bounds
colorSpace:(CGColorSpaceRef)colorSpace NS_AVAILABLE(10_11,9_0);
#pragma mark -
/* Runs the context's garbage collector to reclaim any resources that
* are no longer required (e.g. removes textures from the texture cache
* that reference deleted images.) This method is called automatically
* after every rendering operation. */
- (void)reclaimResources NS_AVAILABLE_MAC(10_4);
/* Frees any cached data (such as temporary images) associated with the
* context. This also runs the garbage collector. */
- (void)clearCaches NS_AVAILABLE(10_4,10_0);
/* Returns the maximum dimension for input images that can be processed
* on the context. */
- (CGSize)inputImageMaximumSize NS_AVAILABLE_IOS(5_0);
/* Returns the maximum dimension for image that can be rendered
* on the context. */
- (CGSize)outputImageMaximumSize NS_AVAILABLE_IOS(5_0);
@end
@interface CIContext (createCGImage)
/* Render the region 'fromRect' of image 'image' into a temporary buffer using
* the context, then create and return a new CoreGraphics image with
* the results. The caller is responsible for releasing the returned image.
* The return value will be null if size is empty or too big. */
- (nullable CGImageRef)createCGImage:(CIImage *)image
fromRect:(CGRect)fromRect
CF_RETURNS_RETAINED;
/* Create a new CGImage from the specified subrect of the image. If
* non-nil the new image will be created in the specified format and colorspace.
* The CGColorSpace must be kCGColorSpaceModelRGB or kCGColorSpaceModelMonochrome
* and must match the specified CIFormat.
* This will return null if fromRect is empty or infinite or the format isn't supported.
*/
- (nullable CGImageRef)createCGImage:(CIImage *)image
fromRect:(CGRect)fromRect
format:(CIFormat)format
colorSpace:(nullable CGColorSpaceRef)colorSpace
CF_RETURNS_RETAINED;
/* Create a new CGImage from the specified subrect of the image.
* The new CGImageRef will be created in the specified format and colorspace.
* The return value will be null if fromRect is empty or infinite.
* The CGColorSpace must be kCGColorSpaceModelRGB or kCGColorSpaceModelMonochrome
* and must match the specified CIFormat.
* This will return null if fromRect is empty or infinite or the format isn't supported.
* If deferred is NO, then the CIImage will be rendered once when this method is called.
* If deferred is YES, then the CIImage will be rendered whenever the CGImage is rendered.
*/
- (nullable CGImageRef)createCGImage:(CIImage *)image
fromRect:(CGRect)fromRect
format:(CIFormat)format
colorSpace:(nullable CGColorSpaceRef)colorSpace
deferred:(BOOL)deferred
CF_RETURNS_RETAINED NS_AVAILABLE(10_12,10_0);
@end
@interface CIContext (OfflineGPUSupport)
/* Not all GPUs will be driving a display. If they are offline we can still use them
* to do work with Core Image. This method returns the number of offline GPUs which
* can be used for this purpose */
+(unsigned int)offlineGPUCount NS_AVAILABLE_MAC(10_10);
/* These two methods lets you create a CIContext based on an offline gpu index.
* The first method takes only the GPU index as a parameter, the second, takes
* an optional colorspace, options dictionary and a CGLContext which can be
* shared with other GL resources. The return value will be null if index is
* out of range (e.g. if the device has no offline GPUs).
*/
#if TARGET_OS_OSX
+ (nullable CIContext *)contextForOfflineGPUAtIndex:(unsigned int)index CI_GL_DEPRECATED_MAC(10_10,10_14);
+ (nullable CIContext *)contextForOfflineGPUAtIndex:(unsigned int)index
colorSpace:(nullable CGColorSpaceRef)colorSpace
options:(nullable NSDictionary<CIContextOption, id> *)options
sharedContext:(nullable CGLContextObj)sharedContext CI_GL_DEPRECATED_MAC(10_10,10_14);
#endif
@end
typedef NSString * CIImageRepresentationOption NS_TYPED_ENUM;
@interface CIContext (ImageRepresentation)
CORE_IMAGE_EXPORT CIImageRepresentationOption const kCIImageRepresentationAVDepthData NS_AVAILABLE(10_13,11_0);
CORE_IMAGE_EXPORT CIImageRepresentationOption const kCIImageRepresentationDepthImage NS_AVAILABLE(10_13,11_0);
CORE_IMAGE_EXPORT CIImageRepresentationOption const kCIImageRepresentationDisparityImage NS_AVAILABLE(10_13,11_0);
CORE_IMAGE_EXPORT CIImageRepresentationOption const kCIImageRepresentationAVPortraitEffectsMatte NS_AVAILABLE(10_14,12_0);
CORE_IMAGE_EXPORT CIImageRepresentationOption const kCIImageRepresentationPortraitEffectsMatteImage NS_AVAILABLE(10_14,12_0);
/* Render a CIImage to TIFF data. Image must have a finite non-empty extent. */
/* The CGColorSpace must be kCGColorSpaceModelRGB or kCGColorSpaceModelMonochrome */
/* and must match the specified CIFormat. */
/* No options keys are supported at this time. */
- (nullable NSData*) TIFFRepresentationOfImage:(CIImage*)image
format:(CIFormat)format
colorSpace:(CGColorSpaceRef)colorSpace
options:(NSDictionary<CIImageRepresentationOption, id>*)options NS_AVAILABLE(10_12,10_0);
/* Render a CIImage to JPEG data. Image must have a finite non-empty extent. */
/* The CGColorSpace must be kCGColorSpaceModelRGB or kCGColorSpaceModelMonochrome. */
/* Supported options keys are kCGImageDestinationLossyCompressionQuality, */
/* kCIImageRepresentationAVDepthData, kCIImageRepresentationDepthImage, */
/* kCIImageRepresentationDisparityImage, kCIImageRepresentationAVPortraitEffectsMatte, */
/* kCIImageRepresentationPortraitEffectsMatteImage. */
- (nullable NSData*) JPEGRepresentationOfImage:(CIImage*)image
colorSpace:(CGColorSpaceRef)colorSpace
options:(NSDictionary<CIImageRepresentationOption, id>*)options NS_AVAILABLE(10_12,10_0);
/* Render a CIImage to HEIF data. Image must have a finite non-empty extent. */
/* The CGColorSpace must be kCGColorSpaceModelRGB or kCGColorSpaceModelMonochrome */
/* and must match the specified CIFormat. */
/* Supported options keys are kCGImageDestinationLossyCompressionQuality, */
/* kCIImageRepresentationAVDepthData, kCIImageRepresentationDepthImage, */
/* kCIImageRepresentationDisparityImage, kCIImageRepresentationAVPortraitEffectsMatte, */
/* kCIImageRepresentationPortraitEffectsMatteImage. */
- (nullable NSData*) HEIFRepresentationOfImage:(CIImage*)image
format:(CIFormat)format
colorSpace:(CGColorSpaceRef)colorSpace
options:(NSDictionary<CIImageRepresentationOption, id>*)options NS_AVAILABLE(10_13_4,11_0);
/* Render a CIImage to PNG data. Image must have a finite non-empty extent. */
/* The CGColorSpace must be kCGColorSpaceModelRGB or kCGColorSpaceModelMonochrome */
/* and must match the specified CIFormat. */
/* No options keys are supported at this time. */
- (nullable NSData*) PNGRepresentationOfImage:(CIImage*)image
format:(CIFormat)format
colorSpace:(CGColorSpaceRef)colorSpace
options:(NSDictionary<CIImageRepresentationOption, id>*)options NS_AVAILABLE(10_13,11_0);
/* Render a CIImage to TIFF file. Image must have a finite non-empty extent. */
/* The CGColorSpace must be kCGColorSpaceModelRGB or kCGColorSpaceModelMonochrome */
/* and must match the specified CIFormat. */
/* No options keys are supported at this time. */
- (BOOL) writeTIFFRepresentationOfImage:(CIImage*)image
toURL:(NSURL*)url
format:(CIFormat)format
colorSpace:(CGColorSpaceRef)colorSpace
options:(NSDictionary<CIImageRepresentationOption, id>*)options
error:(NSError **)errorPtr NS_AVAILABLE(10_12,10_0);
/* Render a CIImage to PNG file. Image must have a finite non-empty extent. */
/* The CGColorSpace must be kCGColorSpaceModelRGB or kCGColorSpaceModelMonochrome */
/* and must match the specified CIFormat. */
/* No options keys are supported at this time. */
- (BOOL) writePNGRepresentationOfImage:(CIImage*)image
toURL:(NSURL*)url
format:(CIFormat)format
colorSpace:(CGColorSpaceRef)colorSpace
options:(NSDictionary<CIImageRepresentationOption, id>*)options
error:(NSError **)errorPtr NS_AVAILABLE(10_13,11_0);
/* Render a CIImage to JPEG file. Image must have a finite non-empty extent. */
/* The CGColorSpace must be kCGColorSpaceModelRGB or kCGColorSpaceModelMonochrome. */
/* Supported options keys are kCGImageDestinationLossyCompressionQuality, */
/* kCIImageRepresentationAVDepthData, kCIImageRepresentationDepthImage, */
/* kCIImageRepresentationDisparityImage, kCIImageRepresentationAVPortraitEffectsMatte, */
/* kCIImageRepresentationPortraitEffectsMatteImage. */
- (BOOL) writeJPEGRepresentationOfImage:(CIImage*)image
toURL:(NSURL*)url
colorSpace:(CGColorSpaceRef)colorSpace
options:(NSDictionary<CIImageRepresentationOption, id>*)options
error:(NSError **)errorPtr NS_AVAILABLE(10_12,10_0);
/* Render a CIImage to HEIF file. Image must have a finite non-empty extent. */
/* The CGColorSpace must be kCGColorSpaceModelRGB or kCGColorSpaceModelMonochrome */
/* and must match the specified CIFormat. */
/* Supported options keys are kCGImageDestinationLossyCompressionQuality, */
/* kCIImageRepresentationAVDepthData, kCIImageRepresentationDepthImage, */
/* kCIImageRepresentationDisparityImage, kCIImageRepresentationAVPortraitEffectsMatte, */
/* kCIImageRepresentationPortraitEffectsMatteImage. */
- (BOOL) writeHEIFRepresentationOfImage:(CIImage*)image
toURL:(NSURL*)url
format:(CIFormat)format
colorSpace:(CGColorSpaceRef)colorSpace
options:(NSDictionary<CIImageRepresentationOption, id>*)options
error:(NSError **)errorPtr NS_AVAILABLE(10_13_4,11_0);
@end
@interface CIContext (CIDepthBlurEffect)
/* Create and CIFilter instance for 'image' that can be used to apply the CIDepthBlurEffect.
*
* The receiver context is user to render the image in order to get the facial landmarks
*
* The 'options' parameter is a key value/pair reserved for future use.
*
*/
- (nullable CIFilter *) depthBlurEffectFilterForImageURL:(NSURL *)url options:(nullable NSDictionary *)options NS_AVAILABLE(10_14,12_0);
/* This is the same as the method above expect it uses NSData to instantiate the image data
* instead of the contents of a NSURL.
*
*/
- (nullable CIFilter *) depthBlurEffectFilterForImageData:(NSData *)data options:(nullable NSDictionary *)options NS_AVAILABLE(10_14,12_0);
/* Create and CIFilter instance for 'image' that can be used to apply the CIDepthBlurEffect.
*
* The receiver context is user to render the image in order to get the facial landmarks
*
* The 'orientation' parameter should be CGImagePropertyOrientation enum value
* as defined in the TIFF spec.
*
* The 'options' parameter is a key value/pair reserved for future use.
*
*/
- (nullable CIFilter *) depthBlurEffectFilterForImage:(CIImage *)image
disparityImage:(CIImage *)disparityImage
portraitEffectsMatte:(nullable CIImage *)portraitEffectsMatte
orientation:(CGImagePropertyOrientation)orientation
options:(nullable NSDictionary *)options NS_AVAILABLE(10_14,12_0);
- (nullable CIFilter *) depthBlurEffectFilterForImage:(CIImage *)image
disparityImage:(CIImage *)disparityImage
portraitEffectsMatte:(nullable CIImage *)portraitEffectsMatte
hairSemanticSegmentation:(nullable CIImage *)hairSemanticSegmentation
orientation:(CGImagePropertyOrientation)orientation
options:(nullable NSDictionary *)options NS_AVAILABLE(10_15,13_0);
@end
NS_ASSUME_NONNULL_END
// ========== CoreImage.framework/Headers/CIRenderDestination.h
/*
CoreImage - CIRenderDestination.h
Copyright (c) 2017 Apple, Inc.
All rights reserved.
*/
#import <Foundation/Foundation.h>
#import <CoreImage/CoreImageDefines.h>
#import <CoreImage/CIImage.h>
#import <CoreImage/CIContext.h>
#import <CoreImage/CIKernel.h>
#import <CoreVideo/CoreVideo.h>
#if COREIMAGE_SUPPORTS_IOSURFACE
#import <IOSurface/IOSurfaceObjC.h>
#endif
#import <Metal/MTLPixelFormat.h>
@protocol MTLTexture, MTLCommandBuffer;
NS_ASSUME_NONNULL_BEGIN
// This is a lightweight API to allow clients to specify all the
// attributes of a render that pertain to the render's destination.
// It is intended to be used for issuing renders that return to the
// caller as soon as all the work has been issued but before it completes/
//
NS_CLASS_AVAILABLE(10_13, 11_0)
@interface CIRenderDestination : NSObject
{
void *_priv;
}
// MARK: PixelBuffer destinations
// Create a CIRenderDestination based on a CVPixelBufferRef object.
//
// The destination's 'colorspace' property will default a CGColorSpace created by,
// querying the CVPixelBufferRef attributes.
//
- (instancetype) initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer;
// MARK: Surface destinations
#if COREIMAGE_SUPPORTS_IOSURFACE
// Create a CIRenderDestination based on an IOSurface object.
//
// The destination's 'colorspace' property will default a CGColorSpace created by,
// querying the IOSurface attributes.
//
- (instancetype) initWithIOSurface:(IOSurface*)surface;
#endif
// MARK: Metal destinations
// A render to a MTLTexture-backed CIRenderDestination is only supported by MTLTexture-backed CIContexts.
// The texture must have a MTLTextureType of MTLTextureType2D
//
// An optional MTLCommandBuffer can be specified, with which to use for rendering to the MTLTexture.
//
// The destination's 'colorspace' property will default a CGColorSpace created with kCGColorSpaceSRGB,
// kCGColorSpaceExtendedSRGB, or kCGColorSpaceGenericGrayGamma2_2.
//
- (instancetype) initWithMTLTexture:(id<MTLTexture>)texture
commandBuffer:(nullable id<MTLCommandBuffer>)commandBuffer;
// Create a CIRenderDestination based on a Metal texture.
//
// Rendering to a MTLTexture-backed CIRenderDestination is only supported by MTLTexture-backed CIContexts.
// The provider 'block' will be called lazily when the destination is rendered to.
// The block must return a texture with a MTLTextureType of MTLTextureType2D.
// The 'width', 'height' and 'pixelFormat' argument values should be the same as the
// width, height and pixelFormat of the MTLTexture that will be returned by 'block'
//
// An optional MTLCommandBuffer can be specified, with which to use for rendering to the MTLTexture.
//
// The destination's 'colorspace' property will default a CGColorSpace created with kCGColorSpaceSRGB,
// kCGColorSpaceExtendedSRGB, or kCGColorSpaceGenericGrayGamma2_2.
//
- (instancetype) initWithWidth:(NSUInteger)width
height:(NSUInteger)height
pixelFormat:(MTLPixelFormat)pixelFormat
commandBuffer:(nullable id<MTLCommandBuffer>)commandBuffer
mtlTextureProvider:(nullable id<MTLTexture> (^)(void))block;
// MARK: OpenGL destination
// Create a CIRenderDestination based on an OpenGL texture.
//
// Rendering to a GLTexture-backed CIRenderDestination is only supported by GLContext-backed CIContexts.
// The texture id must be bound to a GLContext that is shared with that of the GLContext-backed CIContext.
//
// The destination's 'colorspace' property will default a CGColorSpace created with kCGColorSpaceSRGB,
// kCGColorSpaceExtendedSRGB, or kCGColorSpaceGenericGrayGamma2_2.
//
- (instancetype) initWithGLTexture:(unsigned int)texture
target:(unsigned int)target // GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_EXT
width:(NSUInteger)width
height:(NSUInteger)height;
// MARK: Bitmap data destination
// Create a CIRenderDestination based on client-managed buffer.
//
// The 'data' parameter must point to a buffer that is at least bytesPerRow * height bytes in size.
//
// The destination's 'colorspace' property will default a CGColorSpace created with kCGColorSpaceSRGB,
// kCGColorSpaceExtendedSRGB, or kCGColorSpaceGenericGrayGamma2_2.
- (instancetype) initWithBitmapData:(void *)data
width:(NSUInteger)width
height:(NSUInteger)height
bytesPerRow:(NSUInteger)bytesPerRow
format:(CIFormat)format;
// MARK: Properties
@property (readonly) NSUInteger width;
@property (readonly) NSUInteger height;
typedef NS_ENUM(NSUInteger, CIRenderDestinationAlphaMode) {
CIRenderDestinationAlphaNone = 0,
CIRenderDestinationAlphaPremultiplied = 1,
CIRenderDestinationAlphaUnpremultiplied = 2
};
// This property will defualt to an appropriate value given
// the object that the CIRenderDestination was initialized with.
// This property can be set to a different value if desired.
@property CIRenderDestinationAlphaMode alphaMode;
// The logical coordinate system of a CIRenderDestination is always cartesian:
// (0,0) represents the lower-left corner
// (0.5,0.5) represents the lower-left pixel center
// (pixelsWide-0.5,pixelsHigh-0.5) represents the upper-right pixel center
// (pixelsWide,pixelsHigh) represents the upper-right corner.
//
// The 'flipped' property controls how pixels this logical coordinate system
// are stored into the memory of the object backing the destination.
//
// If 'flipped' is false, then the base address of the backing stores the
// pixel centered on the logical coordinate (0.5,0.5)
//
// If 'flipped' is true, then the base address of the backing stores the
// pixel centered on the logical coordinate (0.5,height-0.5)
//
@property (getter=isFlipped) BOOL flipped;
// Instructs the render to add pseudo-random luma noise given the depth of the destination.
// The magnitude of the noise is approximatly ±pow(2,-(bitPerComponent+1))
@property (getter=isDithered) BOOL dithered;
// If true, the render will clamp color channels
// to 0..alpha if 'alphaMode' is premultiplied otherwise 0..1
// This property is initialized to false if the destination's format supports extended range
@property (getter=isClamped) BOOL clamped;
// This property will defualt to an appropriate value given
// the object that the CIRenderDestination was initialized with.
// This property can be set to a different colorSpace if desired.
// This property can be set to nil to disable color matching
// from the working space to the destination.
@property (nullable, nonatomic) CGColorSpaceRef colorSpace;
// Allow client to specify a CIBlendKernel (e.g. CIBlendKernel.sourceOver)
// to be used on the destination.
@property (nullable, nonatomic, retain) CIBlendKernel* blendKernel;
// If true, then the blendKernel is applied in the destination's colorSpace.
// If false, then the blendKernel is applied in the CIContext's working colorspace.
// This is false by default.
@property BOOL blendsInDestinationColorSpace;
@end
// An Xcode quicklook of this object will show a graph visualization of the render
// with detailed timing information.
NS_CLASS_AVAILABLE(10_13, 11_0)
@interface CIRenderInfo : NSObject
{
void *_priv;
}
// This property will return how much time a render spent executing kernels.
@property (readonly) NSTimeInterval kernelExecutionTime;
// This property will return how many passes the render requires.
// If passCount is 1 than the render can be fully concatinated and no
// intermediate buffers will be required.
@property (readonly) NSInteger passCount;
// This property will return how many pixels a render produced executing kernels.
@property (readonly) NSInteger pixelsProcessed;
@end
// An Xcode quicklook of this object will show a graph visualization of the render
NS_CLASS_AVAILABLE(10_13, 11_0)
@interface CIRenderTask : NSObject
{
void *_priv;
}
- (nullable CIRenderInfo*) waitUntilCompletedAndReturnError:(NSError**)error;
@end
@interface CIContext (CIRenderDestination)
// Renders a portion of image to a point of destination
// It renders as if 'image' is cropped to 'fromRect'
// and the origin of the result is placed at 'atPoint'
//
// If image.extent and fromRect are infinite, then it renders
// so that point (0,0) of image is placed at 'atPoint'
//
// MTLTexture-backed CIRenderDestinations are only supported by MTLTexture-backed CIContexts.
// GLTexture-backed CIRenderDestinations are only supported by GLContext-backed CIContexts.
//
// This call will return as soon as all the work for the render is enqueued on the
// context's device.
//
// In many situations, after issuing a render, the client can use the destination
// or its backing object without waiting for the enqueued work to complete.
// For example, after rendering a surface CIRenderDestination, the surface can be passed
// on for further processing by the GPU.
//
// In other situations, the client may need to wait for the render to be complete.
// For example, after rendering a surface CIRenderDestination, the surface can be accessed
// by CPU code by calling IOSurfaceGetBytePointer only after the render is completed.
//
// In this case the client can use the returned CIRenderTask like this:
// CIRenderTask* task = [context render:...];
// [task waitUntilCompletedAndReturnError:&error];
//
- (nullable CIRenderTask*) startTaskToRender:(CIImage*)image
fromRect:(CGRect)fromRect
toDestination:(CIRenderDestination*)destination
atPoint:(CGPoint)atPoint
error:(NSError**)error NS_AVAILABLE(10_13, 11_0);
// Renders an image to a destination so that point (0,0) of image.
// is placed at point (0,0) of the destination.
//
- (nullable CIRenderTask*) startTaskToRender:(CIImage*)image
toDestination:(CIRenderDestination*)destination
error:(NSError**)error NS_AVAILABLE(10_13, 11_0);
// This is an optional call which can be used to "warm up" a CIContext so that
// a subsequent call to render with the same arguments can be more efficient.
// By making this call, Core Image will ensure that
// - any needed kernels will be compiled
// - any intermedate buffers are allocated and marked volatile
//
- (BOOL) prepareRender:(CIImage*)image
fromRect:(CGRect)fromRect
toDestination:(CIRenderDestination*)destination
atPoint:(CGPoint)atPoint
error:(NSError**)error NS_AVAILABLE(10_13, 11_0);
// Fill the entire destination with black (0,0,0,1) if its alphaMode is None
// or clear (0,0,0,0) if its alphaMode is Premultiplied or Unpremultiplied.
//
- (nullable CIRenderTask*) startTaskToClear:(CIRenderDestination*)destination
error:(NSError**)error NS_AVAILABLE(10_13, 11_0);
@end
NS_ASSUME_NONNULL_END
// ========== CoreImage.framework/Headers/CIFeature.h
/* CoreImage - CIFeature.h
Copyright (c) 2011 Apple, Inc.
All rights reserved. */
#import <CoreImage/CoreImageDefines.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/** Generic feature found by a CIDetector. */
NS_CLASS_AVAILABLE(10_7, 5_0)
@interface CIFeature : NSObject {}
/** The type of the feature. */
@property (readonly, retain) NSString *type;
/** The bounds of the feature in the image it was detected in. */
@property (readonly, assign) CGRect bounds;
@end
/** Specifies the type of a feature that is a face. */
CORE_IMAGE_EXPORT NSString* const CIFeatureTypeFace;
/** Specifies the type of a feature that is a rectangle. */
CORE_IMAGE_EXPORT NSString* const CIFeatureTypeRectangle;
/** Specifies the type of a feature that is a QR code. */
CORE_IMAGE_EXPORT NSString* const CIFeatureTypeQRCode;
/** Specifies the type of a feature that is a text. */
CORE_IMAGE_EXPORT NSString* const CIFeatureTypeText;
/** A face feature found by a CIDetector.
All positions are relative to the original image. */
NS_CLASS_AVAILABLE(10_7, 5_0)
@interface CIFaceFeature : CIFeature
{
CGRect bounds;
BOOL hasLeftEyePosition;
CGPoint leftEyePosition;
BOOL hasRightEyePosition;
CGPoint rightEyePosition;
BOOL hasMouthPosition;
CGPoint mouthPosition;
BOOL hasTrackingID;
int trackingID;
BOOL hasTrackingFrameCount;
int trackingFrameCount;
BOOL hasFaceAngle;
float faceAngle;
BOOL hasSmile;
BOOL leftEyeClosed;
BOOL rightEyeClosed;
}
/** coordinates of various cardinal points within a face.
Note that the left eye is the eye on the left side of the face
from the observer's perspective. It is not the left eye from
the subject's perspective. */
@property (readonly, assign) CGRect bounds;
@property (readonly, assign) BOOL hasLeftEyePosition;
@property (readonly, assign) CGPoint leftEyePosition;
@property (readonly, assign) BOOL hasRightEyePosition;
@property (readonly, assign) CGPoint rightEyePosition;
@property (readonly, assign) BOOL hasMouthPosition;
@property (readonly, assign) CGPoint mouthPosition;
@property (readonly, assign) BOOL hasTrackingID;
@property (readonly, assign) int trackingID;
@property (readonly, assign) BOOL hasTrackingFrameCount;
@property (readonly, assign) int trackingFrameCount;
@property (readonly, assign) BOOL hasFaceAngle;
@property (readonly, assign) float faceAngle;
@property (readonly, assign) BOOL hasSmile;
@property (readonly, assign) BOOL leftEyeClosed;
@property (readonly, assign) BOOL rightEyeClosed;
@end
/** A rectangle feature found by a CIDetector
All positions are relative to the original image. */
NS_CLASS_AVAILABLE(10_10, 8_0)
@interface CIRectangleFeature : CIFeature
{
CGRect bounds;
CGPoint topLeft;
CGPoint topRight;
CGPoint bottomLeft;
CGPoint bottomRight;
}
@property (readonly) CGRect bounds;
@property (readonly) CGPoint topLeft;
@property (readonly) CGPoint topRight;
@property (readonly) CGPoint bottomLeft;
@property (readonly) CGPoint bottomRight;
@end
/** A QR code feature found by a CIDetector
All positions are relative to the original image. */
@class CIQRCodeDescriptor;
NS_CLASS_AVAILABLE(10_10, 8_0)
@interface CIQRCodeFeature : CIFeature <NSSecureCoding, NSCopying>
{
CGRect bounds;
CGPoint topLeft;
CGPoint topRight;
CGPoint bottomLeft;
CGPoint bottomRight;
CIQRCodeDescriptor *symbolDescriptor;
}
@property (readonly) CGRect bounds;
@property (readonly) CGPoint topLeft;
@property (readonly) CGPoint topRight;
@property (readonly) CGPoint bottomLeft;
@property (readonly) CGPoint bottomRight;
@property (nullable, readonly) NSString* messageString;
@property (nullable, readonly) CIQRCodeDescriptor *symbolDescriptor NS_AVAILABLE(10_13, 11_0);
@end
/** A text feature found by a CIDetector
All positions are relative to the original image. */
#if __OBJC2__
NS_CLASS_AVAILABLE(10_11, 9_0)
@interface CITextFeature : CIFeature
{
}
@property (readonly) CGRect bounds;
@property (readonly) CGPoint topLeft;
@property (readonly) CGPoint topRight;
@property (readonly) CGPoint bottomLeft;
@property (readonly) CGPoint bottomRight;
@property (nullable, readonly) NSArray *subFeatures;
@end
#endif // __OBJC2__
NS_ASSUME_NONNULL_END
// ========== CoreImage.framework/Headers/CIFilter.h
/*
CoreImage - CIFilter.h
Copyright (c) 2015 Apple, Inc.
All rights reserved.
*/
#import <Foundation/Foundation.h>
#import <CoreImage/CoreImageDefines.h>
#import <CoreImage/CIFilterConstructor.h>
NS_ASSUME_NONNULL_BEGIN
/* Filter attributes keys */
/** Name of the filter */
CORE_IMAGE_EXPORT NSString * const kCIAttributeFilterName;
/** Name of the filter intended for UI display (eg. localized) */
CORE_IMAGE_EXPORT NSString * const kCIAttributeFilterDisplayName;
/** Description of the filter intended for UI display (eg. localized) */
CORE_IMAGE_EXPORT NSString * const kCIAttributeDescription NS_AVAILABLE(10_5, 9_0);
/** The version of OS X and iOS a filter was first available in. */
CORE_IMAGE_EXPORT NSString * const kCIAttributeFilterAvailable_Mac NS_AVAILABLE(10_11, 9_0);
CORE_IMAGE_EXPORT NSString * const kCIAttributeFilterAvailable_iOS NS_AVAILABLE(10_11, 9_0);
/** URL for the reference documentation of the filter. See localizedReferenceDocumentationForFilterName. */
CORE_IMAGE_EXPORT NSString * const kCIAttributeReferenceDocumentation NS_AVAILABLE(10_5, 9_0);
/** Array of filter category names (see below) */
CORE_IMAGE_EXPORT NSString * const kCIAttributeFilterCategories;
/** Class name of the filter. */
CORE_IMAGE_EXPORT NSString * const kCIAttributeClass;
/** The type of the attribute e.g. scalar, time, distance, etc. */
CORE_IMAGE_EXPORT NSString * const kCIAttributeType;
/** Minimum value for the attribute. */
CORE_IMAGE_EXPORT NSString * const kCIAttributeMin;
/** Maximum value for the attribute. */
CORE_IMAGE_EXPORT NSString * const kCIAttributeMax;
/** Minimum value for the slider. */
CORE_IMAGE_EXPORT NSString * const kCIAttributeSliderMin;
/** Maximum value for the slider. */
CORE_IMAGE_EXPORT NSString * const kCIAttributeSliderMax;
/** Default value for the slider. */
CORE_IMAGE_EXPORT NSString * const kCIAttributeDefault;
/** The identity value is the value at which the filter has no effect. */
CORE_IMAGE_EXPORT NSString * const kCIAttributeIdentity;