1 /**
2 Dynamic bindings to the CoreImage framework.
3 
4 Copyright: Guillaume Piolat 2016.
5 License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
6 */
7 module derelict.cocoa.coreimage;
8 
9 import derelict.cocoa.runtime;
10 import derelict.cocoa.foundation;
11 import derelict.cocoa.coregraphics;
12 
13 
14 struct CIContext
15 {
16 nothrow @nogc:
17     NSObject parent;
18     alias parent this;
19 
20     mixin NSObjectTemplate!(CIContext, "CIContext");
21 
22     void drawImage(CIImage image, CGRect inRect, CGRect fromRect)
23     {
24         alias fun_t = extern(C) void function (id obj, SEL sel, id, CGRect, CGRect) nothrow @nogc;
25         (cast(fun_t)objc_msgSend)(_id, sel!"drawImage:inRect:fromRect:", image._id, inRect, fromRect);
26     }
27 }
28 
29 alias CIFormat = int;
30 
31 extern(C)
32 {
33     __gshared CIFormat kCIFormatARGB8;
34     __gshared CIFormat kCIFormatRGBA16;
35     __gshared CIFormat kCIFormatRGBAf;
36     __gshared CIFormat kCIFormatRGBAh;
37 }
38 
39 struct CIImage
40 {
41 nothrow @nogc:
42     NSObject parent;
43     alias parent this;
44 
45     mixin NSObjectTemplate!(CIImage, "CIImage");
46 
47     static CIImage imageWithBitmapData(NSData d, size_t bytesPerRow, CGSize size, CIFormat f, CGColorSpaceRef cs)
48     {
49         alias fun_t = extern(C) id function (id obj, SEL sel, id, NSUInteger, CGSize, CIFormat, CGColorSpaceRef) nothrow @nogc;
50         id result = (cast(fun_t)objc_msgSend)(getClassID(),
51                                  sel!"imageWithBitmapData:bytesPerRow:size:format:colorSpace:",
52                                  d._id, cast(NSUInteger)bytesPerRow, size, f, cs);
53         return CIImage(result);
54     }
55 }