Exemplo n.º 1
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");
            }
        }
        public CGColorConversionInfo(NSDictionary options, params GColorConversionInfoTriple [] triples)
        {
            // the API won't return a valid instance if no triple is given, i.e. at least one is needed.
            // `null` is accepted to mark the end of the list, not to make it optional
            if ((triples == null) || (triples.Length == 0))
            {
                throw new ArgumentNullException("triples");
            }
            if (triples.Length > 3)
            {
                throw new ArgumentException("A maximum of 3 triples are supported");
            }

            IntPtr o      = NativeObjectHelper.GetHandle(options);
            var    first  = triples [0];         // there's always one
            var    second = triples.Length > 1 ? triples [1] : empty;
            var    third  = triples.Length > 2 ? triples [2] : empty;

#if !MONOMAC
            if (Runtime.IsARM64CallingConvention)
            {
                Handle = CGColorConversionInfoCreateFromList_arm64(o, NativeObjectHelper.GetHandle(first.Space), (uint)first.Transform, (int)first.Intent,
                                                                   IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero,
                                                                   NativeObjectHelper.GetHandle(second.Space), (uint)second.Transform, (int)second.Intent,
                                                                   NativeObjectHelper.GetHandle(third.Space), (uint)third.Transform, (int)third.Intent,
                                                                   IntPtr.Zero);
            }
            else
            {
#endif
            Handle = CGColorConversionInfoCreateFromList(o, NativeObjectHelper.GetHandle(first.Space), first.Transform, first.Intent,
                                                         NativeObjectHelper.GetHandle(second.Space), second.Transform, second.Intent,
                                                         NativeObjectHelper.GetHandle(third.Space), third.Transform, third.Intent,
                                                         IntPtr.Zero);
#if !MONOMAC
        }
#endif
            if (Handle == IntPtr.Zero)
            {
                throw new Exception("Failed to create CGColorConverter");
            }
        }
Exemplo n.º 3
0
        public CGColorConverter(NSDictionary options, params CGColorConverterTriple [] triples)
        {
            // the API won't return a valid instance if no triple is given, i.e. at least one is needed.
            // `null` is accepted to mark the end of the list, not to make it optional
            if ((triples == null) || (triples.Length == 0))
            {
                throw new ArgumentNullException("triples");
            }
            if (triples.Length > 3)
            {
                throw new ArgumentException("A maximum of 3 triples are supported");
            }

            IntPtr o      = NativeObjectHelper.GetHandle(options);
            var    first  = triples [0];         // there's always one
            var    second = triples.Length > 1 ? triples [1] : empty;
            var    third  = triples.Length > 2 ? triples [2] : empty;

            if ((IntPtr.Size == 8) && (Runtime.Arch == Arch.DEVICE))
            {
                handle = CGColorConverterCreate_arm64(o, NativeObjectHelper.GetHandle(first.Space), (long)first.Transform, (long)first.Intent,
                                                      IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero,
                                                      NativeObjectHelper.GetHandle(second.Space), (long)second.Transform, (long)second.Intent,
                                                      NativeObjectHelper.GetHandle(third.Space), (long)third.Transform, (long)third.Intent,
                                                      IntPtr.Zero);
            }
            else
            {
                handle = CGColorConverterCreate(o, NativeObjectHelper.GetHandle(first.Space), first.Transform, first.Intent,
                                                NativeObjectHelper.GetHandle(second.Space), second.Transform, second.Intent,
                                                NativeObjectHelper.GetHandle(third.Space), third.Transform, third.Intent,
                                                IntPtr.Zero);
            }

            if (handle == IntPtr.Zero)
            {
                throw new Exception("Failed to create CGColorConverter");
            }
        }