Esempio n. 1
0
        public void SetPropertyItem(PropertyItem propitem)
        {
            if (propitem == null)
            {
                throw new ArgumentNullException(nameof(propitem));
            }

            int    nItemSize = Marshal.SizeOf(propitem.Value[0]);
            int    size      = nItemSize * propitem.Value.Length;
            IntPtr dest      = Marshal.AllocHGlobal(size);

            try
            {
                GdipPropertyItem pi = new GdipPropertyItem();
                pi.id   = propitem.Id;
                pi.len  = propitem.Len;
                pi.type = propitem.Type;

                Marshal.Copy(propitem.Value, 0, dest, size);
                pi.value = dest;

                unsafe
                {
                    int status = Gdip.GdipSetPropertyItem(nativeImage, &pi);

                    Gdip.CheckStatus(status);
                }
            }
            finally
            {
                Marshal.FreeHGlobal(dest);
            }
        }
Esempio n. 2
0
        public PropertyItem GetPropertyItem(int propid)
        {
            int              propSize;
            IntPtr           property;
            PropertyItem     item         = new PropertyItem();
            GdipPropertyItem gdipProperty = new GdipPropertyItem();
            int              status;

            status = Gdip.GdipGetPropertyItemSize(nativeImage, propid,
                                                  out propSize);
            Gdip.CheckStatus(status);

            /* Get PropertyItem */
            property = Marshal.AllocHGlobal(propSize);
            try
            {
                status = Gdip.GdipGetPropertyItem(nativeImage, propid, propSize, property);
                Gdip.CheckStatus(status);
                gdipProperty = (GdipPropertyItem)Marshal.PtrToStructure(property,
                                                                        typeof(GdipPropertyItem));
                GdipPropertyItem.MarshalTo(gdipProperty, item);
            }
            finally
            {
                Marshal.FreeHGlobal(property);
            }
            return(item);
        }
Esempio n. 3
0
 internal static void MarshalTo(GdipPropertyItem gdipProp, PropertyItem prop)
 {
     prop.Id    = gdipProp.id;
     prop.Len   = gdipProp.len;
     prop.Type  = gdipProp.type;
     prop.Value = new byte[gdipProp.len];
     Marshal.Copy(gdipProp.value, prop.Value, 0, gdipProp.len);
 }
Esempio n. 4
0
		internal unsafe static extern Status GdipSetPropertyItem (IntPtr image, GdipPropertyItem *propertyItem);
Esempio n. 5
0
	public PropertyItem GetPropertyItem(int propid)
	{
		int propSize;
		IntPtr property;
		PropertyItem item = new PropertyItem ();
		GdipPropertyItem gdipProperty = new GdipPropertyItem ();
		Status status;
			
		status = GDIPlus.GdipGetPropertyItemSize (nativeObject, propid, 
									out propSize);
		GDIPlus.CheckStatus (status);

		/* Get PropertyItem */
		property = Marshal.AllocHGlobal (propSize);
		try {
			status = GDIPlus.GdipGetPropertyItem (nativeObject, propid, propSize, property);
			GDIPlus.CheckStatus (status);
			gdipProperty = (GdipPropertyItem) Marshal.PtrToStructure (property, 
								typeof (GdipPropertyItem));						
			GdipPropertyItem.MarshalTo (gdipProperty, item);
		}
		finally {
			Marshal.FreeHGlobal (property);
		}
		return item;
	}
Esempio n. 6
0
		internal static void MarshalTo (GdipPropertyItem gdipProp, PropertyItem prop)
		{	
			prop.Id = gdipProp.id;
			prop.Len = gdipProp.len;
			prop.Type = gdipProp.type;
			prop.Value = new byte [gdipProp.len];			
			Marshal.Copy (gdipProp.value, prop.Value, 0, gdipProp.len);
		}