Esempio n. 1
0
        internal static void SetImageCustomProperty(Image image, CustomPropertyTag customPropertyTag, string text)
        {
            PropertyItem propertyItem = (PropertyItem)typeof(PropertyItem).GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic)[0].Invoke(null);

            propertyItem.Id    = (int)customPropertyTag;
            propertyItem.Type  = 1;
            propertyItem.Value = Encoding.Unicode.GetBytes(text);
            propertyItem.Len   = propertyItem.Value.Length;
            image.SetPropertyItem(propertyItem);
        }
Esempio n. 2
0
        public static void SetImageCustomProperty(Image image, CustomPropertyTag customPropertyTag, string text)
        {
            Type            typeFromHandle  = typeof(PropertyItem);
            ConstructorInfo constructorInfo = typeFromHandle.GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic)[0];
            PropertyItem    propertyItem    = (PropertyItem)constructorInfo.Invoke(null);

            propertyItem.Id    = (int)customPropertyTag;
            propertyItem.Type  = 1;
            propertyItem.Value = Encoding.Unicode.GetBytes(text);
            propertyItem.Len   = propertyItem.Value.Length;
            image.SetPropertyItem(propertyItem);
        }
Esempio n. 3
0
 internal static string GetImageCustomProperty(Image image, CustomPropertyTag customPropertyTag)
 {
     try
     {
         PropertyItem[] propertyItems = image.PropertyItems;
         foreach (PropertyItem propertyItem in propertyItems)
         {
             if (propertyItem.Id == (int)customPropertyTag && propertyItem.Value != null)
             {
                 return(Encoding.Unicode.GetString(propertyItem.Value));
             }
         }
     }
     catch
     {
         return(string.Empty);
     }
     return(string.Empty);
 }