Exemplo n.º 1
0
		public CGColor (CGColorSpace colorspace, nfloat [] components)
		{
			if (components == null)
				throw new ArgumentNullException ("components");
			if (colorspace == null)
				throw new ArgumentNullException ("colorspace");
			if (colorspace.handle == IntPtr.Zero)
				throw new ObjectDisposedException ("colorspace");
			
			handle = CGColorCreate (colorspace.handle, components);
		}
Exemplo n.º 2
0
		public static CGShading CreateAxial (CGColorSpace colorspace, CGPoint start, CGPoint end, CGFunction function, bool extendStart, bool extendEnd)
		{
			if (colorspace == null)
				throw new ArgumentNullException ("colorspace");
			if (colorspace.Handle == IntPtr.Zero)
				throw new ObjectDisposedException ("colorspace");
			if (function == null)
				throw new ArgumentNullException ("function");
			if (function.Handle == IntPtr.Zero)
				throw new ObjectDisposedException ("function");

			return new CGShading (CGShadingCreateAxial (colorspace.Handle, start, end, function.Handle, extendStart, extendEnd), true);
		}
Exemplo n.º 3
0
		public CGColor (CGColorSpace colorspace, CGPattern pattern, nfloat [] components)
		{
			if (colorspace == null)
				throw new ArgumentNullException ("colorspace");
			if (colorspace.handle == IntPtr.Zero)
				throw new ObjectDisposedException ("colorspace");
			if (pattern == null)
				throw new ArgumentNullException ("pattern");
			if (components == null)
				throw new ArgumentNullException ("components");

			handle = CGColorCreateWithPattern (colorspace.handle, pattern.handle, components);
			if (handle == IntPtr.Zero)
				throw new ArgumentException ();
		}
Exemplo n.º 4
0
 public CIImage(ICIImageProvider provider, nuint width, nuint height, CIFormat pixelFormat, CGColorSpace colorSpace, CIImageProviderOptions options)
     : this(provider, width, height, CIImage.CIFormatToInt (pixelFormat), colorSpace, options == null ? null : options.Dictionary)
 {
 }
Exemplo n.º 5
0
 public CGBitmapContext(byte [] data, nint width, nint height, nint bitsPerComponent, nint bytesPerRow, CGColorSpace colorSpace, CGBitmapFlags bitmapInfo)
 {
     if (data != null)
         buffer = GCHandle.Alloc (data, GCHandleType.Pinned);
     Handle = CGBitmapContextCreate (data, width, height, bitsPerComponent, bytesPerRow, GetHandle (colorSpace), (uint) bitmapInfo);
 }
Exemplo n.º 6
0
        public static CGColorSpace CreateICCProfile(nfloat[] range, CGDataProvider profile, CGColorSpace alternate)
#endif
        {
            nint   nComponents = range == null ? 0 : range.Length / 2;
            IntPtr p           = profile == null ? IntPtr.Zero : profile.Handle;
            IntPtr a           = alternate == null ? IntPtr.Zero : alternate.Handle;
            var    ptr         = CGColorSpaceCreateICCBased(nComponents, range, p, a);

            return(ptr == IntPtr.Zero ? null : new CGColorSpace(ptr, true));
        }
Exemplo n.º 7
0
		public CGGradient (CGColorSpace colorspace, CGColor [] colors)
		{
			if (colors == null)
				throw new ArgumentNullException ("colors");
			
			IntPtr csh = colorspace == null ? IntPtr.Zero : colorspace.handle;
			using (var array = CFArray.FromNativeObjects (colors))
				handle = CGGradientCreateWithColors (csh, array.Handle, null);
		}
Exemplo n.º 8
0
 public static CIImage FromData(NSData bitmapData, nint bytesPerRow, CGSize size, CIFormat pixelFormat, CGColorSpace colorSpace)
 {
     return FromData (bitmapData, bytesPerRow, size, CIImage.CIFormatToInt (pixelFormat), colorSpace);
 }
Exemplo n.º 9
0
        public static CGColorSpace CreatePattern(CGColorSpace baseSpace)
        {
            var ptr = CGColorSpaceCreatePattern(baseSpace == null ? IntPtr.Zero : baseSpace.handle);

            return(ptr == IntPtr.Zero ? null : new CGColorSpace(ptr, true));
        }
Exemplo n.º 10
0
		public static CGColorSpace CreatePattern (CGColorSpace baseSpace)
		{
			var ptr = CGColorSpaceCreatePattern (baseSpace == null ? IntPtr.Zero : baseSpace.handle);
			return ptr == IntPtr.Zero ? null : new CGColorSpace (ptr, true);
		}
Exemplo n.º 11
0
        public CGImage WithColorSpace(CGColorSpace cs)
        {
            var h = CGImageCreateCopyWithColorSpace(handle, cs == null ? IntPtr.Zero : cs.handle);

            return(h == IntPtr.Zero ? null : new CGImage(h, true));
        }
Exemplo n.º 12
0
		public void SetStrokeColorSpace (CGColorSpace space)
		{
			CGContextSetStrokeColorSpace (handle, space == null ? IntPtr.Zero : space.handle);
		}
Exemplo n.º 13
0
		public static CGColorSpace CreateIndexed (CGColorSpace baseSpace, int lastIndex, byte[] colorTable)
		{
			var ptr = CGColorSpaceCreateIndexed (baseSpace == null ? IntPtr.Zero : baseSpace.handle, lastIndex, colorTable);
			return ptr == IntPtr.Zero ? null : new CGColorSpace (ptr, true);
		}
Exemplo n.º 14
0
 public CGBitmapContext(byte [] data, nint width, nint height, nint bitsPerComponent, nint bytesPerRow, CGColorSpace colorSpace, CGBitmapFlags bitmapInfo)
 {
     if (data != null)
     {
         buffer = GCHandle.Alloc(data, GCHandleType.Pinned);
     }
     Handle = CGBitmapContextCreate(data, width, height, bitsPerComponent, bytesPerRow, GetHandle(colorSpace), (uint)bitmapInfo);
 }
Exemplo n.º 15
0
 public CGImage CreateCGImage(CIImage image, CGRect fromRect, CIFormat ciImageFormat, CGColorSpace colorSpace)
 {
     return CreateCGImage (image, fromRect, CIImage.CIFormatToInt (ciImageFormat), colorSpace);
 }
Exemplo n.º 16
0
 public static CIImage FromProvider(ICIImageProvider provider, nuint width, nuint height, CIFormat pixelFormat, CGColorSpace colorSpace, CIImageProviderOptions options)
 {
     return FromProvider (provider, width, height, CIImage.CIFormatToInt (pixelFormat), colorSpace, options == null ? null : options.Dictionary);
 }
Exemplo n.º 17
0
		static CGColor CreateByMatchingToColorSpace (CGColorSpace space, CGColorRenderingIntent intent,
			CGColor color, NSDictionary options)
		{
			var h = CGColorCreateCopyByMatchingToColorSpace (space == null ? IntPtr.Zero : space.Handle, intent,
				color == null ? IntPtr.Zero : color.Handle, options == null ? IntPtr.Zero : options.Handle);
			return h == IntPtr.Zero ? null : new CGColor (h);
		}
Exemplo n.º 18
0
 public CGBitmapContext(byte [] data, nint width, nint height, nint bitsPerComponent, nint bytesPerRow, CGColorSpace colorSpace, CGBitmapFlags bitmapInfo)
 {
     if (data != null)
     {
         buffer = GCHandle.Alloc(data, GCHandleType.Pinned);                  // This requires a pinned GCHandle, because unsafe code is scoped to the current block, and the address of the byte array will be used after this function returns.
     }
     Handle = CGBitmapContextCreate(data, width, height, bitsPerComponent, bytesPerRow, GetHandle(colorSpace), (uint)bitmapInfo);
 }
Exemplo n.º 19
0
		public static CGColorSpace CreateICCProfile (nfloat[] range, CGDataProvider profile, CGColorSpace alternate)
		{
			nint nComponents = range == null ? 0 : range.Length / 2;
			IntPtr p = profile == null ? IntPtr.Zero : profile.Handle;
			IntPtr a = alternate == null ? IntPtr.Zero : alternate.Handle;
			var ptr = CGColorSpaceCreateICCBased (nComponents, range, p, a);
			return ptr == IntPtr.Zero ? null : new CGColorSpace (ptr, true);
		}
Exemplo n.º 20
0
        public static CIImage FromCGImage(CGImage image, CGColorSpace colorSpace)
        {
            if (colorSpace == null)
                throw new ArgumentNullException ("colorSpace");

            using (var arr = NSArray.FromIntPtrs (new IntPtr [] { colorSpace.Handle })){
                using (var keys = NSArray.FromIntPtrs (new IntPtr [] { CIImageColorSpaceKey.Handle } )){
                    using (var dict = NSDictionary.FromObjectsAndKeysInternal (arr, keys)){
                        return FromCGImage (image, dict);
                    }
                }
            }
        }
Exemplo n.º 21
0
 public CGBitmapContext(IntPtr data, nint width, nint height, nint bitsPerComponent, nint bytesPerRow, CGColorSpace colorSpace, CGBitmapFlags bitmapInfo)
     : base(CGBitmapContextCreate(data, width, height, bitsPerComponent, bytesPerRow, GetHandle(colorSpace), (uint)bitmapInfo), true)
 {
 }
Exemplo n.º 22
0
        public CGColorConverter(CGColorSpace from, CGColorSpace to)
        {
            handle = CGColorConverterCreateSimple (NativeObjectHelper.GetHandle (from), NativeObjectHelper.GetHandle (to));

            if (handle == IntPtr.Zero)
                throw new Exception ("Failed to create CGColorConverter");
        }
Exemplo n.º 23
0
        public static CGColorSpace CreateIndexed(CGColorSpace baseSpace, int lastIndex, byte[] colorTable)
        {
            var ptr = CGColorSpaceCreateIndexed(baseSpace == null ? IntPtr.Zero : baseSpace.handle, lastIndex, colorTable);

            return(ptr == IntPtr.Zero ? null : new CGColorSpace(ptr, true));
        }
Exemplo n.º 24
0
		public CGImage (int width, int height, int bitsPerComponent, int bitsPerPixel, int bytesPerRow,
				CGColorSpace colorSpace, CGImageAlphaInfo alphaInfo, CGDataProvider provider,
				nfloat [] decode, bool shouldInterpolate, CGColorRenderingIntent intent)
		{
			if (width < 0)
				throw new ArgumentException ("width");
			if (height < 0)
				throw new ArgumentException ("height");
			if (bitsPerPixel < 0)
				throw new ArgumentException ("bitsPerPixel");
			if (bitsPerComponent < 0)
				throw new ArgumentException ("bitsPerComponent");
			if (bytesPerRow < 0)
				throw new ArgumentException ("bytesPerRow");

			handle = CGImageCreate (width, height, bitsPerComponent, bitsPerPixel, bytesPerRow,
						colorSpace == null ? IntPtr.Zero : colorSpace.Handle, (CGBitmapFlags) alphaInfo, provider == null ? IntPtr.Zero : provider.Handle,
						decode,
						shouldInterpolate, intent);
		}
Exemplo n.º 25
0
 public static CGColorSpace CreateIccProfile(nfloat[] range, CGDataProvider profile, CGColorSpace alternate)
Exemplo n.º 26
0
		public CGImage WithColorSpace (CGColorSpace cs)
		{
			var h = CGImageCreateCopyWithColorSpace (handle, cs == null ? IntPtr.Zero : cs.handle);
			return h == IntPtr.Zero ? null : new CGImage (h, true);
		}
Exemplo n.º 27
0
		public CGGradient (CGColorSpace colorspace, CGColor [] colors, nfloat [] locations)
		{
			// colors is __nullable but would return a `nil` instance back,
			// which is not something we can handle nicely from a .NET constructor
			if (colors == null)
				throw new ArgumentNullException ("colors");
			
			IntPtr csh = colorspace == null ? IntPtr.Zero : colorspace.handle;
			using (var array = CFArray.FromNativeObjects (colors))
				handle = CGGradientCreateWithColors (csh, array.Handle, locations);
		}
Exemplo n.º 28
0
 static IntPtr GetHandle(CGColorSpace colorSpace)
 {
     if (colorSpace == null)
         return IntPtr.Zero;
     return colorSpace.Handle;
 }
Exemplo n.º 29
0
		public CGGradient (CGColorSpace colorspace, nfloat [] components, nfloat [] locations)
		{
			// those parameters are __nullable but would return a `nil` instance back,
			// which is not something we can handle nicely from a .NET constructor
			if (colorspace == null)
				throw new ArgumentNullException ("colorspace");
			if (components == null)
				throw new ArgumentNullException ("components");

			handle = CGGradientCreateWithColorComponents (colorspace.handle, components, locations, components.Length / (colorspace.Components+1));
		}
Exemplo n.º 30
0
 public CGBitmapContext(IntPtr data, nint width, nint height, nint bitsPerComponent, nint bytesPerRow, CGColorSpace colorSpace, CGBitmapFlags bitmapInfo)
     : base(CGBitmapContextCreate (data, width, height, bitsPerComponent, bytesPerRow, GetHandle (colorSpace), (uint) bitmapInfo), true)
 {
 }