Exemple #1
0
 public static string GetShowString(Exif exif)
 {
     string showString = "";
     if (!string.IsNullOrEmpty(exif.bySoftware))
         showString += "�������:" + exif.bySoftware + "<br />";
     if (!string.IsNullOrEmpty(exif.datetime))
         showString += "����ʱ��;" + exif.datetime + "<br />";
     if (!string.IsNullOrEmpty(exif.isoSpeed))
         showString += "iso�ٶ�:" + exif.isoSpeed + "<br />";
     if (!string.IsNullOrEmpty(exif.equipmentMake))
         showString += "���:" + exif.equipmentMake + "<br />";
     if (!string.IsNullOrEmpty(exif.exposureTime))
         showString += "�ع�ʱ��:" + exif.exposureTime + "<br />";
     if (!string.IsNullOrEmpty(exif.flash))
         showString += "�����:" + exif.flash + "<br />";
     if (!string.IsNullOrEmpty(exif.xResolution))
         showString += "ˮƽ�ֱ���:" + exif.xResolution + "<br />";
     if (!string.IsNullOrEmpty(exif.yResolution))
         showString += "��ֱ�ֱ���:" + exif.yResolution + "<br />";
     if (!string.IsNullOrEmpty(exif.yResolution))
         showString += "��Ƭ���:" + exif.imageWidth + "<br />";
     if (!string.IsNullOrEmpty(exif.yResolution))
         showString += "��Ƭ�߶�:" + exif.imageHeight + "<br />";
     if (!string.IsNullOrEmpty(exif.yResolution))
         showString += "��Ȧ��:" + exif.fNumber;
     return showString;
 }
Exemple #2
0
        public static string GetShowString(Exif exif)
        {
            string showString = "";

            if (!string.IsNullOrEmpty(exif.bySoftware))
            {
                showString += "�������:" + exif.bySoftware + "<br />";
            }
            if (!string.IsNullOrEmpty(exif.datetime))
            {
                showString += "����ʱ��;" + exif.datetime + "<br />";
            }
            if (!string.IsNullOrEmpty(exif.isoSpeed))
            {
                showString += "iso�ٶ�:" + exif.isoSpeed + "<br />";
            }
            if (!string.IsNullOrEmpty(exif.equipmentMake))
            {
                showString += "���:" + exif.equipmentMake + "<br />";
            }
            if (!string.IsNullOrEmpty(exif.exposureTime))
            {
                showString += "�ع�ʱ��:" + exif.exposureTime + "<br />";
            }
            if (!string.IsNullOrEmpty(exif.flash))
            {
                showString += "�����:" + exif.flash + "<br />";
            }
            if (!string.IsNullOrEmpty(exif.xResolution))
            {
                showString += "ˮƽ�ֱ���:" + exif.xResolution + "<br />";
            }
            if (!string.IsNullOrEmpty(exif.yResolution))
            {
                showString += "��ֱ�ֱ���:" + exif.yResolution + "<br />";
            }
            if (!string.IsNullOrEmpty(exif.yResolution))
            {
                showString += "��Ƭ���:" + exif.imageWidth + "<br />";
            }
            if (!string.IsNullOrEmpty(exif.yResolution))
            {
                showString += "��Ƭ�߶�:" + exif.imageHeight + "<br />";
            }
            if (!string.IsNullOrEmpty(exif.yResolution))
            {
                showString += "��Ȧ��:" + exif.fNumber;
            }
            return(showString);
        }
Exemple #3
0
        public static Exif Parse(string strFormat)
        {
            Exif exif = new Exif();

            try
            {
                string          info  = Regex.Match(strFormat, @"\d+(@.+?:\d+)+sun").Value;
                MatchCollection mc    = Regex.Matches(info, @"@(.*?):(\d+)");
                string          value = strFormat.Replace(info, "");
                int             start = 0;
                foreach (Match match in mc)
                {
                    int lenght = int.Parse(match.Groups[2].Value);
                    exif.GetType().GetProperty(match.Groups[1].Value).SetValue(exif, value.Substring(start, lenght), null);
                    start += lenght;
                }
            }
            catch
            {
                return(new Exif());
            }
            return(exif);
        }
Exemple #4
0
 public static Exif Parse(string strFormat)
 {
     Exif exif = new Exif();
     try
     {
         string info = Regex.Match(strFormat, @"\d+(@.+?:\d+)+sun").Value;
         MatchCollection mc = Regex.Matches(info, @"@(.*?):(\d+)");
         string value = strFormat.Replace(info, "");
         int start = 0;
         foreach (Match match in mc)
         {
             int lenght = int.Parse(match.Groups[2].Value);
             exif.GetType().GetProperty(match.Groups[1].Value).SetValue(exif, value.Substring(start, lenght), null);
             start += lenght;
         }
     }
     catch
     {
         return new Exif();
     }
     return exif;
 }
Exemple #5
0
        public static Exif ExifAnalyse(Stream stream)
        {
            Exif exif = new Exif();
            try
            {
                // ����һ��ͼƬ��ʵ��
                /******************************************************
                 * ���ܳ���
                 * 
                 *System.ArgumentException:
                 * 
                 *        ����û����Ч��ͼ���ʽ- �� -stream Ϊ null��
                 * 
                 * modify:����try{}catch{}��myxbing,2007-8-31
                 * *****************************************************/
                Image MyImage = Image.FromStream(stream);
                // ����һ�������������洢ͼ�������������ID
                int[] MyPropertyIdList = MyImage.PropertyIdList;
                //����һ�����ͼ�����������ʵ��
                PropertyItem[] MyPropertyItemList = new PropertyItem[MyPropertyIdList.Length];

                // ASCII����
                System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();

                int index = 0;
                int MyPropertyIdListCount = MyPropertyIdList.Length;
                if (MyPropertyIdListCount != 0)
                {
                    foreach (int MyPropertyId in MyPropertyIdList)
                    {
                        MyPropertyItemList[index] = MyImage.GetPropertyItem(MyPropertyId);

                        #region ��ʼ��������ֵ
                        string myPropertyIdString = MyImage.GetPropertyItem(MyPropertyId).Id.ToString("x");
                        switch (myPropertyIdString)
                        {
                            case "131":
                                exif.BySoftware = asciiEncoding.GetString(MyPropertyItemList[index].Value);
                                break;
                            case "132":
                                exif.DateTime = asciiEncoding.GetString(MyPropertyItemList[index].Value);
                                break;
                            case "829a":
                                exif.ExposureTime = GetExposureTimeValue(MyPropertyItemList[index].Value);
                                break;
                            case "829d":
                                exif.FNumber = GetFnumberValue(MyPropertyItemList[index].Value);
                                break;
                            case "9209":       //�����
                                exif.Flash = BoolToEXIFValue(MyPropertyItemList[index].Value);
                                break;
                            case "8827":
                                exif.IsoSpeed = "ISO-" + ShortToEXIFValue(MyPropertyItemList[index].Value);
                                break;
                            case "10f":
                                exif.EquipmentMake = asciiEncoding.GetString(MyPropertyItemList[index].Value);
                                break;
                        }
                        #endregion
                        index++;
                    }
                }

                exif.XResolution = MyImage.HorizontalResolution.ToString() + "DPI";
                exif.YResolution = MyImage.VerticalResolution.ToString() + "DPI";
                exif.ImageHeight = MyImage.Height.ToString();
                exif.ImageWidth = MyImage.Width.ToString();
                MyImage.Dispose();
            }
            catch
            {
            }
            return exif;
        }