comparison dstep/quartzcore/CIImage.d @ 16:19885b43130e

Huge update, the bridge actually works now
author Jacob Carlborg <doob@me.com>
date Sun, 03 Jan 2010 22:06:11 +0100
parents
children f8a3b67adfcb
comparison
equal deleted inserted replaced
15:7ff919f595d5 16:19885b43130e
1 /**
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
3 * Authors: Jacob Carlborg
4 * Version: Initial created: Sep 24, 2009
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
6 */
7 module dstep.quartzcore.CIImage;
8
9 import dstep.applicationservices.ApplicationServices;
10 import dstep.corevideo.CVImageBuffer;
11 import dstep.foundation.NSCoder;
12 import dstep.foundation.NSData;
13 import dstep.foundation.NSDictionary;
14 import dstep.foundation.NSObject;
15 import dstep.foundation.NSString;
16 import dstep.foundation.NSURL;
17 import dstep.foundation.NSZone;
18 import dstep.objc.bridge.Bridge;
19 import dstep.objc.objc;
20 import dstep.quartzcore.CIColor;
21 import dstep.quartzcore.CIContext;
22 import dstep.quartzcore.CIFilterShape;
23 import dstep.quartzcore.CIImageProvider;
24
25 import bindings = dstep.quartzcore.CIImage_bindings;
26
27 alias int CIFormat;
28
29 extern (C)
30 {
31 extern
32 {
33 int kCIFormatARGB8;
34 int kCIFormatRGBA16;
35 int kCIFormatRGBAf;
36 }
37 }
38
39 private
40 {
41 NSString kCIImageColorSpace_;
42 }
43
44 NSString kCIImageColorSpace ()
45 {
46 if (kCIImageColorSpace_)
47 return kCIImageColorSpace_;
48
49 return kCIImageColorSpace_ = new NSString(bindings.kCIImageColorSpace);
50 }
51
52 class CIImage : NSObject, INSCoding, INSCopying
53 {
54 mixin (ObjcWrap);
55
56 typeof(this) copyWithZone (NSZone* zone)
57 {
58 return invokeObjcSelf!(typeof(this), "copyWithZone:", NSZone*)(zone);
59 }
60
61 this (NSCoder aDecoder)
62 {
63 super(typeof(this).alloc.initWithCoder(aDecoder).objcObject);
64 }
65
66 void encodeWithCoder (NSCoder aCoder)
67 {
68 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
69 }
70
71 typeof(this) initWithCoder (NSCoder aDecoder)
72 {
73 return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder);
74 }
75
76 typeof(this) copyWithZone (NSZone* zone)
77 {
78 return invokeObjcSelf!(typeof(this), "copyWithZone:", NSZone*)(zone);
79 }
80
81 static CIImage imageWithCGImage (CGImageRef image)
82 {
83 return invokeObjcSelfClass!(CIImage, "imageWithCGImage:", CGImageRef)(image);
84 }
85
86 static CIImage imageWithCGImage (CGImageRef image, NSDictionary d)
87 {
88 return invokeObjcSelfClass!(CIImage, "imageWithCGImage:options:", CGImageRef, NSDictionary)(image, d);
89 }
90
91 static CIImage imageWithCGLayer (CGLayerRef layer)
92 {
93 return invokeObjcSelfClass!(CIImage, "imageWithCGLayer:", CGLayerRef)(layer);
94 }
95
96 static CIImage imageWithCGLayer (CGLayerRef layer, NSDictionary d)
97 {
98 return invokeObjcSelfClass!(CIImage, "imageWithCGLayer:options:", CGLayerRef, NSDictionary)(layer, d);
99 }
100
101 static CIImage imageWithBitmapData (NSData d, uint bpr, CGSize size, int f, CGColorSpaceRef cs)
102 {
103 return invokeObjcSelfClass!(CIImage, "imageWithBitmapData:bytesPerRow:size:format:colorSpace:", NSData, uint, CGSize, int, CGColorSpaceRef)(d, bpr, size, f, cs);
104 }
105
106 static CIImage imageWithTexture (uint name, CGSize size, bool flag, CGColorSpaceRef cs)
107 {
108 return invokeObjcSelfClass!(CIImage, "imageWithTexture:size:flipped:colorSpace:", uint, CGSize, bool, CGColorSpaceRef)(name, size, flag, cs);
109 }
110
111 static CIImage imageWithContentsOfURL (NSURL url)
112 {
113 return invokeObjcSelfClass!(CIImage, "imageWithContentsOfURL:", NSURL)(url);
114 }
115
116 static CIImage imageWithContentsOfURL (NSURL url, NSDictionary d)
117 {
118 return invokeObjcSelfClass!(CIImage, "imageWithContentsOfURL:options:", NSURL, NSDictionary)(url, d);
119 }
120
121 static CIImage imageWithData (NSData data)
122 {
123 return invokeObjcSelfClass!(CIImage, "imageWithData:", NSData)(data);
124 }
125
126 static CIImage imageWithData (NSData data, NSDictionary d)
127 {
128 return invokeObjcSelfClass!(CIImage, "imageWithData:options:", NSData, NSDictionary)(data, d);
129 }
130
131 static CIImage imageWithCVImageBuffer (CVImageBufferRef imageBuffer)
132 {
133 return invokeObjcSelfClass!(CIImage, "imageWithCVImageBuffer:", CVImageBufferRef)(imageBuffer);
134 }
135
136 static CIImage imageWithCVImageBuffer (CVImageBufferRef imageBuffer, NSDictionary dict)
137 {
138 return invokeObjcSelfClass!(CIImage, "imageWithCVImageBuffer:options:", CVImageBufferRef, NSDictionary)(imageBuffer, dict);
139 }
140
141 static CIImage imageWithColor (CIColor color)
142 {
143 return invokeObjcSelfClass!(CIImage, "imageWithColor:", CIColor)(color);
144 }
145
146 static CIImage emptyImage ()
147 {
148 return invokeObjcSelfClass!(CIImage, "emptyImage");
149 }
150
151 CIImage initWithCGImage (CGImageRef image)
152 {
153 id result = invokeObjcSelf!(id, "initWithCGImage:", CGImageRef)(image);
154 return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null);
155 }
156
157 this (CGImageRef image)
158 {
159 super(CIImage.alloc.initWithCGImage(image).objcObject);
160 }
161
162 CIImage initWithCGImage (CGImageRef image, NSDictionary d)
163 {
164 id result = invokeObjcSelf!(id, "initWithCGImage:options:", CGImageRef, NSDictionary)(image, d);
165 return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null);
166 }
167
168 this (CGImageRef image, NSDictionary d)
169 {
170 super(CIImage.alloc.initWithCGImage(image, d).objcObject);
171 }
172
173 CIImage initWithCGLayer (CGLayerRef layer)
174 {
175 id result = invokeObjcSelf!(id, "initWithCGLayer:", CGLayerRef)(layer);
176 return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null);
177 }
178
179 this (CGLayerRef layer)
180 {
181 super(CIImage.alloc.initWithCGLayer(layer).objcObject);
182 }
183
184 CIImage initWithCGLayer (CGLayerRef layer, NSDictionary d)
185 {
186 id result = invokeObjcSelf!(id, "initWithCGLayer:options:", CGLayerRef, NSDictionary)(layer, d);
187 return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null);
188 }
189
190 this (CGLayerRef layer, NSDictionary d)
191 {
192 super(CIImage.alloc.initWithCGLayer(layer, d).objcObject);
193 }
194
195 CIImage initWithData (NSData data)
196 {
197 id result = invokeObjcSelf!(id, "initWithData:", NSData)(data);
198 return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null);
199 }
200
201 this (NSData data)
202 {
203 super(CIImage.alloc.initWithData(data).objcObject);
204 }
205
206 CIImage initWithData (NSData data, NSDictionary d)
207 {
208 id result = invokeObjcSelf!(id, "initWithData:options:", NSData, NSDictionary)(data, d);
209 return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null);
210 }
211
212 this (NSData data, NSDictionary d)
213 {
214 super(CIImage.alloc.initWithData(data, d).objcObject);
215 }
216
217 CIImage initWithBitmapData (NSData d, uint bpr, CGSize size, int f, CGColorSpaceRef c)
218 {
219 id result = invokeObjcSelf!(id, "initWithBitmapData:bytesPerRow:size:format:colorSpace:", NSData, uint, CGSize, int, CGColorSpaceRef)(d, bpr, size, f, c);
220 return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null);
221 }
222
223 this (NSData d, uint bpr, CGSize size, int f, CGColorSpaceRef c)
224 {
225 super(CIImage.alloc.initWithBitmapData(d, bpr, size, f, c).objcObject);
226 }
227
228 CIImage initWithTexture (uint name, CGSize size, bool flag, CGColorSpaceRef cs)
229 {
230 id result = invokeObjcSelf!(id, "initWithTexture:size:flipped:colorSpace:", uint, CGSize, bool, CGColorSpaceRef)(name, size, flag, cs);
231 return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null);
232 }
233
234 this (uint name, CGSize size, bool flag, CGColorSpaceRef cs)
235 {
236 super(CIImage.alloc.initWithTexture(name, size, flag, cs).objcObject);
237 }
238
239 CIImage initWithContentsOfURL (NSURL url)
240 {
241 id result = invokeObjcSelf!(id, "initWithContentsOfURL:", NSURL)(url);
242 return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null);
243 }
244
245 this (NSURL url)
246 {
247 super(CIImage.alloc.initWithContentsOfURL(url).objcObject);
248 }
249
250 CIImage initWithContentsOfURL (NSURL url, NSDictionary d)
251 {
252 id result = invokeObjcSelf!(id, "initWithContentsOfURL:options:", NSURL, NSDictionary)(url, d);
253 return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null);
254 }
255
256 this (NSURL url, NSDictionary d)
257 {
258 super(CIImage.alloc.initWithContentsOfURL(url, d).objcObject);
259 }
260
261 CIImage initWithCVImageBuffer (CVImageBufferRef imageBuffer)
262 {
263 id result = invokeObjcSelf!(id, "initWithCVImageBuffer:", CVImageBufferRef)(imageBuffer);
264 return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null);
265 }
266
267 this (CVImageBufferRef imageBuffer)
268 {
269 super(CIImage.alloc.initWithCVImageBuffer(imageBuffer).objcObject);
270 }
271
272 CIImage initWithCVImageBuffer (CVImageBufferRef imageBuffer, NSDictionary dict)
273 {
274 id result = invokeObjcSelf!(id, "initWithCVImageBuffer:options:", CVImageBufferRef, NSDictionary)(imageBuffer, dict);
275 return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null);
276 }
277
278 this (CVImageBufferRef imageBuffer, NSDictionary dict)
279 {
280 super(CIImage.alloc.initWithCVImageBuffer(imageBuffer, dict).objcObject);
281 }
282
283 CIImage initWithColor (CIColor color)
284 {
285 id result = invokeObjcSelf!(id, "initWithColor:", CIColor)(color);
286 return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null);
287 }
288
289 this (CIColor color)
290 {
291 super(CIImage.alloc.initWithColor(color).objcObject);
292 }
293
294 CIImage imageByApplyingTransform (CGAffineTransform matrix)
295 {
296 id result = invokeObjcSelf!(id, "imageByApplyingTransform:", CGAffineTransform)(matrix);
297 return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null);
298 }
299
300 CIImage imageByCroppingToRect (CGRect r)
301 {
302 id result = invokeObjcSelf!(id, "imageByCroppingToRect:", CGRect)(r);
303 return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null);
304 }
305
306 CGRect extent ()
307 {
308 return invokeObjcSelf!(CGRect, "extent");
309 }
310
311 CIFilterShape definition ()
312 {
313 return invokeObjcSelf!(CIFilterShape, "definition");
314 }
315
316 // CIImageProvider
317 static CIImage imageWithImageProvider (Object p, size_t width, size_t height, CIFormat f, CGColorSpaceRef cs, NSDictionary dict)
318 {
319 return invokeObjcSelfClass!(CIImage, "imageWithImageProvider:size::format:colorSpace:options:", Object, size_t, size_t, CIFormat, CGColorSpaceRef, NSDictionary)(p, width, height, f, cs, dict);
320 }
321
322 typeof(this) initWithImageProvider (Object p, size_t width, size_t height, CIFormat f, CGColorSpaceRef cs, NSDictionary dict)
323 {
324 id result = invokeObjcSelf!(id, "initWithImageProvider:size::format:colorSpace:options:", Object, size_t, size_t, CIFormat, CGColorSpaceRef, NSDictionary)(p, width, height, f, cs, dict);
325 return result is this.objcObject ? this : (result !is null ? new typeof(this)(result) : null);
326 }
327
328 this (Object p, size_t width, size_t height, CIFormat f, CGColorSpaceRef cs, NSDictionary dict)
329 {
330 super(typeof(this).alloc.initWithImageProvider(p, width, height, f, cs, dict).objcObject);
331 }
332
333 }
334