Example #1
0
        internal static PropertyItem[] ConvertFromMemory(IntPtr propdata, int count)
        {
            PropertyItem[] props = new PropertyItem[count];

            for (int i = 0; i < count; i++)
            {
                PropertyItemInternal propcopy = null;
                try
                {
                    propcopy = (PropertyItemInternal)Marshal.PtrToStructure(propdata,
                                                                            typeof(PropertyItemInternal));

                    props[i]      = new PropertyItem();
                    props[i].Id   = propcopy.id;
                    props[i].Len  = propcopy.len;
                    props[i].Type = propcopy.type;

                    // this calls Marshal.Copy and creates a copy of the original memory into a byte array.
                    props[i].Value = propcopy.Value;

                    propcopy.value = IntPtr.Zero;  // we dont actually own this memory so dont free it.
                }
                finally
                {
                    if (propcopy != null)
                    {
                        propcopy.Dispose();
                    }
                }

                propdata = (IntPtr)((long)propdata + (int)Marshal.SizeOf(typeof(PropertyItemInternal)));
            }

            return(props);
        }
Example #2
0
        internal static PropertyItemInternal ConvertFromPropertyItem(PropertyItem propItem) {
            PropertyItemInternal propItemInternal = new PropertyItemInternal();
            propItemInternal.id = propItem.Id;
            propItemInternal.len = 0;
            propItemInternal.type = propItem.Type;

            byte[] propItemValue = propItem.Value;
            if (propItemValue != null) {
                int length = propItemValue.Length;
                propItemInternal.len = length;
                propItemInternal.value = Marshal.AllocHGlobal(length);
                Marshal.Copy(propItemValue, 0, propItemInternal.value, length);
            }

            return propItemInternal;
        }
 internal static PropertyItemInternal ConvertFromPropertyItem(PropertyItem propItem)
 {
     PropertyItemInternal internal2 = new PropertyItemInternal {
         id = propItem.Id,
         len = 0,
         type = propItem.Type
     };
     byte[] source = propItem.Value;
     if (source != null)
     {
         int length = source.Length;
         internal2.len = length;
         internal2.value = Marshal.AllocHGlobal(length);
         Marshal.Copy(source, 0, internal2.value, length);
     }
     return internal2;
 }
Example #4
0
        internal static PropertyItemInternal ConvertFromPropertyItem(PropertyItem propItem)
        {
            PropertyItemInternal propItemInternal = new PropertyItemInternal();

            propItemInternal.id   = propItem.Id;
            propItemInternal.len  = propItem.Len;
            propItemInternal.type = propItem.Type;

            byte[] propItemValue = propItem.Value;
            if (propItemValue != null)
            {
                propItemInternal.value = Marshal.AllocHGlobal(propItemValue.Length);
                Marshal.Copy(propItemValue, 0, propItemInternal.value, propItemValue.Length);
            }

            return(propItemInternal);
        }
Example #5
0
        internal static PropertyItemInternal ConvertFromPropertyItem(PropertyItem propItem)
        {
            PropertyItemInternal internal2 = new PropertyItemInternal {
                id   = propItem.Id,
                len  = 0,
                type = propItem.Type
            };

            byte[] source = propItem.Value;
            if (source != null)
            {
                int length = source.Length;
                internal2.len   = length;
                internal2.value = Marshal.AllocHGlobal(length);
                Marshal.Copy(source, 0, internal2.value, length);
            }
            return(internal2);
        }
Example #6
0
 internal static PropertyItem[] ConvertFromMemory(IntPtr propdata, int count)
 {
     PropertyItem[] itemArray = new PropertyItem[count];
     for (int i = 0; i < count; i++)
     {
         using (PropertyItemInternal internal2 = null)
         {
             internal2          = (PropertyItemInternal)UnsafeNativeMethods.PtrToStructure(propdata, typeof(PropertyItemInternal));
             itemArray[i]       = new PropertyItem();
             itemArray[i].Id    = internal2.id;
             itemArray[i].Len   = internal2.len;
             itemArray[i].Type  = internal2.type;
             itemArray[i].Value = internal2.Value;
             internal2.value    = IntPtr.Zero;
         }
         propdata = (IntPtr)(((long)propdata) + Marshal.SizeOf(typeof(PropertyItemInternal)));
     }
     return(itemArray);
 }
Example #7
0
        internal static PropertyItem[] ConvertFromMemory(IntPtr propdata, int count)
        {
            PropertyItem[] props = new PropertyItem[count];

            for (int i = 0; i < count; i++)
            {
                PropertyItemInternal propcopy = (PropertyItemInternal)UnsafeNativeMethods.PtrToStructure(propdata,
                                                                                                         typeof(PropertyItemInternal));

                props[i]       = new PropertyItem();
                props[i].Id    = propcopy.id;
                props[i].Len   = propcopy.len;
                props[i].Type  = propcopy.type;
                props[i].Value = propcopy.Value;

                propdata = (IntPtr)((long)propdata + (int)Marshal.SizeOf(typeof(PropertyItemInternal)));
            }

            return(props);
        }
Example #8
0
 internal static extern int GdipSetPropertyItem(HandleRef image, PropertyItemInternal propitem);