Beispiel #1
0
        internal static EncoderParameters ConvertFromMemory(IntPtr memory)
        {
            if (memory == IntPtr.Zero)
            {
                throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
            }

            int count = Marshal.ReadIntPtr(memory).ToInt32();

            EncoderParameters p = new EncoderParameters(count);
            int  size           = Marshal.SizeOf(typeof(EncoderParameter));
            long arrayOffset    = (long)memory + Marshal.SizeOf(typeof(IntPtr));

            IntSecurity.UnmanagedCode.Assert();

            try {
                for (int i = 0; i < count; i++)
                {
                    Guid guid                      = (Guid)UnsafeNativeMethods.PtrToStructure((IntPtr)(i * size + arrayOffset), typeof(Guid));
                    int  numberOfValues            = Marshal.ReadInt32((IntPtr)(i * size + arrayOffset + 16));
                    EncoderParameterValueType type = (EncoderParameterValueType)Marshal.ReadInt32((IntPtr)(i * size + arrayOffset + 20));
                    IntPtr value                   = Marshal.ReadIntPtr((IntPtr)(i * size + arrayOffset + 24));

                    p.param[i] = new EncoderParameter(new Encoder(guid), numberOfValues, type, value);
                }
            }
            finally {
                System.Security.CodeAccessPermission.RevertAssert();
            }

            return(p);
        }
Beispiel #2
0
        internal static EncoderParameters ConvertFromMemory(IntPtr memory)
        {
            if (memory == IntPtr.Zero)
            {
                throw SafeNativeMethods.StatusException(SafeNativeMethods.InvalidParameter);
            }

            int count;

            count = Marshal.ReadInt32(memory);

            EncoderParameters p;

            p = new EncoderParameters(count);
            int size = (int)Marshal.SizeOf(typeof(EncoderParameter));

            for (int i = 0; i < count; i++)
            {
                Guid guid;
                guid = (Guid)UnsafeNativeMethods.PtrToStructure((IntPtr)(i * size + (long)memory + 4), typeof(Guid));

                int NumberOfValues;
                NumberOfValues = Marshal.ReadInt32((IntPtr)(i * size + (long)memory + 4 + size - 12));

                int Type;
                Type = Marshal.ReadInt32((IntPtr)(i * size + (long)memory + 4 + size - 8));

                int Value;
                Value = Marshal.ReadInt32((IntPtr)(i * size + (long)memory + 4 + size - 4));

                p.param[i] = new EncoderParameter(new Encoder(guid),
                                                  NumberOfValues,
                                                  Type,
                                                  Value);
            }

            return(p);
        }