Esempio n. 1
0
 static GValue()
 {
     if (NetVips.AtLeastLibvips(8, 6))
     {
         BlendModeType = Vips.BlendModeGetType();
     }
 }
Esempio n. 2
0
        static GValue()
        {
            Vips.BandFormatGetType();
            BandFormatType = NetVips.TypeFromName("VipsBandFormat");

            if (NetVips.AtLeastLibvips(8, 6))
            {
                Vips.BlendModeGetType();
                BlendModeType = NetVips.TypeFromName("VipsBlendMode");
            }
        }
Esempio n. 3
0
        static GValue()
        {
            if (NetVips.AtLeastLibvips(8, 6))
            {
                BlendModeType = Vips.BlendModeGetType();
            }

            if (NetVips.AtLeastLibvips(8, 9))
            {
                SourceType = NetVips.TypeFromName("VipsSource");
                TargetType = NetVips.TypeFromName("VipsTarget");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Get all arguments for an operation.
        /// </summary>
        /// <remarks>
        /// Not quick! Try to call this infrequently.
        /// </remarks>
        /// <param name="operation">Operation to lookup.</param>
        /// <returns>Arguments for the operation.</returns>
        private IEnumerable <KeyValuePair <string, Enums.ArgumentFlags> > GetArgs(Operation operation)
        {
            var args = new List <KeyValuePair <string, Enums.ArgumentFlags> >();

            void AddArg(string name, Enums.ArgumentFlags flags)
            {
                // libvips uses '-' to separate parts of arg names, but we
                // need '_' for C#
                name = name.Replace("-", "_");

                args.Add(new KeyValuePair <string, Enums.ArgumentFlags>(name, flags));
            }

            // vips_object_get_args was added in 8.7
            if (NetVips.AtLeastLibvips(8, 7))
            {
                var result = Internal.VipsObject.GetArgs(operation, out var names, out var flags, out var nArgs);

                if (result != 0)
                {
                    throw new VipsException("unable to get arguments from operation");
                }

                for (var i = 0; i < nArgs; i++)
                {
                    var flag = (Enums.ArgumentFlags)Marshal.PtrToStructure(flags + i * sizeof(int), typeof(int));
                    if ((flag & Enums.ArgumentFlags.CONSTRUCT) == 0)
                    {
                        continue;
                    }

                    var name = Marshal.PtrToStringAnsi(Marshal.ReadIntPtr(names, i * IntPtr.Size));

                    AddArg(name, flag);
                }
            }
            else
            {
                IntPtr AddConstruct(IntPtr self, IntPtr pspec, IntPtr argumentClass, IntPtr argumentInstance,
                                    IntPtr a,
                                    IntPtr b)
                {
                    var flags = argumentClass.Dereference <VipsArgumentClass>().Flags;

                    if ((flags & Enums.ArgumentFlags.CONSTRUCT) == 0)
                    {
                        return(IntPtr.Zero);
                    }

                    var name = Marshal.PtrToStringAnsi(pspec.Dereference <GParamSpec.Struct>().Name);

                    AddArg(name, flags);

                    return(IntPtr.Zero);
                }

                Vips.ArgumentMap(operation, AddConstruct, IntPtr.Zero, IntPtr.Zero);
            }

            return(args);
        }