Exemple #1
0
 public static extern unsafe void GrannyConvertSingleObject(granny_data_type_definition *SourceType,
                                                            void *SourceObject,
                                                            granny_data_type_definition *DestType,
                                                            ref BRenderEffectParamExtendedData DestObject);
Exemple #2
0
        static unsafe public Dictionary <string, string> GetExtendedStringData(granny_variant extendedVariant)
        {
            Dictionary <string, string> hashtable = new Dictionary <string, string>();

            granny_data_type_definition[] extendedDataDef = new granny_data_type_definition[3];
            extendedDataDef[0]            = new granny_data_type_definition();
            extendedDataDef[1]            = new granny_data_type_definition();
            extendedDataDef[2]            = new granny_data_type_definition();
            extendedDataDef[0].memberType = granny_member_type.GrannyStringMember;
            extendedDataDef[1].memberType = granny_member_type.GrannyStringMember;
            extendedDataDef[2].memberType = granny_member_type.GrannyEndMember;

            int i = 0;

            while (true)
            {
                if (extendedVariant.Type[i].memberType == granny_member_type.GrannyEndMember)
                {
                    break;
                }
                if (extendedVariant.Type[i].memberType == granny_member_type.GrannyStringMember)
                {
                    IntPtr p        = new IntPtr((void *)extendedVariant.Type[i].Name);
                    string typename = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(p);

                    hashtable[typename] = "";

                    string name  = typename;
                    string value = typename;

                    System.Text.ASCIIEncoding aenc = new System.Text.ASCIIEncoding();
                    byte[] name0 = aenc.GetBytes(name);
                    byte[] name1 = aenc.GetBytes(value);

                    fixed(byte *nPtr = name0)
                    {
                        fixed(byte *vPtr = name1)
                        {
                            extendedDataDef[0].Name = (char *)nPtr;
                            extendedDataDef[1].Name = (char *)vPtr;

                            BRenderEffectParamExtendedData extendedData = new BRenderEffectParamExtendedData();

                            fixed(granny_data_type_definition *dd = extendedDataDef)
                            GrannyConvertSingleObject(extendedVariant.Type, extendedVariant.Object, dd, ref extendedData);

                            if ((extendedData.paramName == null) || (extendedData.paramValue == null))
                            {
                                break;
                            }

                            p = new IntPtr((void *)extendedData.paramValue);
                            string valstring = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(p);

                            hashtable[typename] = valstring;
                        }
                    }
                }
                i++;
            }
            return(hashtable);
        }