Mercurial > projects > dstep
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dstep/quartzcore/CIImage.d Sun Jan 03 22:06:11 2010 +0100 @@ -0,0 +1,334 @@ +/** + * Copyright: Copyright (c) 2009 Jacob Carlborg. + * Authors: Jacob Carlborg + * Version: Initial created: Sep 24, 2009 + * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) + */ +module dstep.quartzcore.CIImage; + +import dstep.applicationservices.ApplicationServices; +import dstep.corevideo.CVImageBuffer; +import dstep.foundation.NSCoder; +import dstep.foundation.NSData; +import dstep.foundation.NSDictionary; +import dstep.foundation.NSObject; +import dstep.foundation.NSString; +import dstep.foundation.NSURL; +import dstep.foundation.NSZone; +import dstep.objc.bridge.Bridge; +import dstep.objc.objc; +import dstep.quartzcore.CIColor; +import dstep.quartzcore.CIContext; +import dstep.quartzcore.CIFilterShape; +import dstep.quartzcore.CIImageProvider; + +import bindings = dstep.quartzcore.CIImage_bindings; + +alias int CIFormat; + +extern (C) +{ + extern + { + int kCIFormatARGB8; + int kCIFormatRGBA16; + int kCIFormatRGBAf; + } +} + +private +{ + NSString kCIImageColorSpace_; +} + +NSString kCIImageColorSpace () +{ + if (kCIImageColorSpace_) + return kCIImageColorSpace_; + + return kCIImageColorSpace_ = new NSString(bindings.kCIImageColorSpace); +} + +class CIImage : NSObject, INSCoding, INSCopying +{ + mixin (ObjcWrap); + + typeof(this) copyWithZone (NSZone* zone) + { + return invokeObjcSelf!(typeof(this), "copyWithZone:", NSZone*)(zone); + } + + this (NSCoder aDecoder) + { + super(typeof(this).alloc.initWithCoder(aDecoder).objcObject); + } + + void encodeWithCoder (NSCoder aCoder) + { + return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); + } + + typeof(this) initWithCoder (NSCoder aDecoder) + { + return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder); + } + + typeof(this) copyWithZone (NSZone* zone) + { + return invokeObjcSelf!(typeof(this), "copyWithZone:", NSZone*)(zone); + } + + static CIImage imageWithCGImage (CGImageRef image) + { + return invokeObjcSelfClass!(CIImage, "imageWithCGImage:", CGImageRef)(image); + } + + static CIImage imageWithCGImage (CGImageRef image, NSDictionary d) + { + return invokeObjcSelfClass!(CIImage, "imageWithCGImage:options:", CGImageRef, NSDictionary)(image, d); + } + + static CIImage imageWithCGLayer (CGLayerRef layer) + { + return invokeObjcSelfClass!(CIImage, "imageWithCGLayer:", CGLayerRef)(layer); + } + + static CIImage imageWithCGLayer (CGLayerRef layer, NSDictionary d) + { + return invokeObjcSelfClass!(CIImage, "imageWithCGLayer:options:", CGLayerRef, NSDictionary)(layer, d); + } + + static CIImage imageWithBitmapData (NSData d, uint bpr, CGSize size, int f, CGColorSpaceRef cs) + { + return invokeObjcSelfClass!(CIImage, "imageWithBitmapData:bytesPerRow:size:format:colorSpace:", NSData, uint, CGSize, int, CGColorSpaceRef)(d, bpr, size, f, cs); + } + + static CIImage imageWithTexture (uint name, CGSize size, bool flag, CGColorSpaceRef cs) + { + return invokeObjcSelfClass!(CIImage, "imageWithTexture:size:flipped:colorSpace:", uint, CGSize, bool, CGColorSpaceRef)(name, size, flag, cs); + } + + static CIImage imageWithContentsOfURL (NSURL url) + { + return invokeObjcSelfClass!(CIImage, "imageWithContentsOfURL:", NSURL)(url); + } + + static CIImage imageWithContentsOfURL (NSURL url, NSDictionary d) + { + return invokeObjcSelfClass!(CIImage, "imageWithContentsOfURL:options:", NSURL, NSDictionary)(url, d); + } + + static CIImage imageWithData (NSData data) + { + return invokeObjcSelfClass!(CIImage, "imageWithData:", NSData)(data); + } + + static CIImage imageWithData (NSData data, NSDictionary d) + { + return invokeObjcSelfClass!(CIImage, "imageWithData:options:", NSData, NSDictionary)(data, d); + } + + static CIImage imageWithCVImageBuffer (CVImageBufferRef imageBuffer) + { + return invokeObjcSelfClass!(CIImage, "imageWithCVImageBuffer:", CVImageBufferRef)(imageBuffer); + } + + static CIImage imageWithCVImageBuffer (CVImageBufferRef imageBuffer, NSDictionary dict) + { + return invokeObjcSelfClass!(CIImage, "imageWithCVImageBuffer:options:", CVImageBufferRef, NSDictionary)(imageBuffer, dict); + } + + static CIImage imageWithColor (CIColor color) + { + return invokeObjcSelfClass!(CIImage, "imageWithColor:", CIColor)(color); + } + + static CIImage emptyImage () + { + return invokeObjcSelfClass!(CIImage, "emptyImage"); + } + + CIImage initWithCGImage (CGImageRef image) + { + id result = invokeObjcSelf!(id, "initWithCGImage:", CGImageRef)(image); + return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null); + } + + this (CGImageRef image) + { + super(CIImage.alloc.initWithCGImage(image).objcObject); + } + + CIImage initWithCGImage (CGImageRef image, NSDictionary d) + { + id result = invokeObjcSelf!(id, "initWithCGImage:options:", CGImageRef, NSDictionary)(image, d); + return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null); + } + + this (CGImageRef image, NSDictionary d) + { + super(CIImage.alloc.initWithCGImage(image, d).objcObject); + } + + CIImage initWithCGLayer (CGLayerRef layer) + { + id result = invokeObjcSelf!(id, "initWithCGLayer:", CGLayerRef)(layer); + return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null); + } + + this (CGLayerRef layer) + { + super(CIImage.alloc.initWithCGLayer(layer).objcObject); + } + + CIImage initWithCGLayer (CGLayerRef layer, NSDictionary d) + { + id result = invokeObjcSelf!(id, "initWithCGLayer:options:", CGLayerRef, NSDictionary)(layer, d); + return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null); + } + + this (CGLayerRef layer, NSDictionary d) + { + super(CIImage.alloc.initWithCGLayer(layer, d).objcObject); + } + + CIImage initWithData (NSData data) + { + id result = invokeObjcSelf!(id, "initWithData:", NSData)(data); + return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null); + } + + this (NSData data) + { + super(CIImage.alloc.initWithData(data).objcObject); + } + + CIImage initWithData (NSData data, NSDictionary d) + { + id result = invokeObjcSelf!(id, "initWithData:options:", NSData, NSDictionary)(data, d); + return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null); + } + + this (NSData data, NSDictionary d) + { + super(CIImage.alloc.initWithData(data, d).objcObject); + } + + CIImage initWithBitmapData (NSData d, uint bpr, CGSize size, int f, CGColorSpaceRef c) + { + id result = invokeObjcSelf!(id, "initWithBitmapData:bytesPerRow:size:format:colorSpace:", NSData, uint, CGSize, int, CGColorSpaceRef)(d, bpr, size, f, c); + return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null); + } + + this (NSData d, uint bpr, CGSize size, int f, CGColorSpaceRef c) + { + super(CIImage.alloc.initWithBitmapData(d, bpr, size, f, c).objcObject); + } + + CIImage initWithTexture (uint name, CGSize size, bool flag, CGColorSpaceRef cs) + { + id result = invokeObjcSelf!(id, "initWithTexture:size:flipped:colorSpace:", uint, CGSize, bool, CGColorSpaceRef)(name, size, flag, cs); + return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null); + } + + this (uint name, CGSize size, bool flag, CGColorSpaceRef cs) + { + super(CIImage.alloc.initWithTexture(name, size, flag, cs).objcObject); + } + + CIImage initWithContentsOfURL (NSURL url) + { + id result = invokeObjcSelf!(id, "initWithContentsOfURL:", NSURL)(url); + return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null); + } + + this (NSURL url) + { + super(CIImage.alloc.initWithContentsOfURL(url).objcObject); + } + + CIImage initWithContentsOfURL (NSURL url, NSDictionary d) + { + id result = invokeObjcSelf!(id, "initWithContentsOfURL:options:", NSURL, NSDictionary)(url, d); + return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null); + } + + this (NSURL url, NSDictionary d) + { + super(CIImage.alloc.initWithContentsOfURL(url, d).objcObject); + } + + CIImage initWithCVImageBuffer (CVImageBufferRef imageBuffer) + { + id result = invokeObjcSelf!(id, "initWithCVImageBuffer:", CVImageBufferRef)(imageBuffer); + return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null); + } + + this (CVImageBufferRef imageBuffer) + { + super(CIImage.alloc.initWithCVImageBuffer(imageBuffer).objcObject); + } + + CIImage initWithCVImageBuffer (CVImageBufferRef imageBuffer, NSDictionary dict) + { + id result = invokeObjcSelf!(id, "initWithCVImageBuffer:options:", CVImageBufferRef, NSDictionary)(imageBuffer, dict); + return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null); + } + + this (CVImageBufferRef imageBuffer, NSDictionary dict) + { + super(CIImage.alloc.initWithCVImageBuffer(imageBuffer, dict).objcObject); + } + + CIImage initWithColor (CIColor color) + { + id result = invokeObjcSelf!(id, "initWithColor:", CIColor)(color); + return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null); + } + + this (CIColor color) + { + super(CIImage.alloc.initWithColor(color).objcObject); + } + + CIImage imageByApplyingTransform (CGAffineTransform matrix) + { + id result = invokeObjcSelf!(id, "imageByApplyingTransform:", CGAffineTransform)(matrix); + return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null); + } + + CIImage imageByCroppingToRect (CGRect r) + { + id result = invokeObjcSelf!(id, "imageByCroppingToRect:", CGRect)(r); + return result is this.objcObject ? this : (result !is null ? new CIImage(result) : null); + } + + CGRect extent () + { + return invokeObjcSelf!(CGRect, "extent"); + } + + CIFilterShape definition () + { + return invokeObjcSelf!(CIFilterShape, "definition"); + } + + // CIImageProvider + static CIImage imageWithImageProvider (Object p, size_t width, size_t height, CIFormat f, CGColorSpaceRef cs, NSDictionary dict) + { + return invokeObjcSelfClass!(CIImage, "imageWithImageProvider:size::format:colorSpace:options:", Object, size_t, size_t, CIFormat, CGColorSpaceRef, NSDictionary)(p, width, height, f, cs, dict); + } + + typeof(this) initWithImageProvider (Object p, size_t width, size_t height, CIFormat f, CGColorSpaceRef cs, NSDictionary dict) + { + id result = invokeObjcSelf!(id, "initWithImageProvider:size::format:colorSpace:options:", Object, size_t, size_t, CIFormat, CGColorSpaceRef, NSDictionary)(p, width, height, f, cs, dict); + return result is this.objcObject ? this : (result !is null ? new typeof(this)(result) : null); + } + + this (Object p, size_t width, size_t height, CIFormat f, CGColorSpaceRef cs, NSDictionary dict) + { + super(typeof(this).alloc.initWithImageProvider(p, width, height, f, cs, dict).objcObject); + } + +} +