Beispiel #1
0
        public void UpdateImageInfo(string path)
        {
            if (!File.Exists(path))
            {
                return;
            }

            CurrentFile = new FileInfo(path);

            using (Image image = ImageHelper.LoadImageAsBitmap(path))
            {
                if (image == null)
                {
                    return;
                }
                tbLocationDisplay.Text     = path;
                tbSizeDisplay.Text         = Helper.SizeSuffix(CurrentFile.Length);
                tbDateCreatedDisplay.Text  = CurrentFile.CreationTime.ToString();
                tbDateModifiedDisplay.Text = CurrentFile.LastWriteTime.ToString();
                tbDateAccessedDisplay.Text = CurrentFile.LastAccessTime.ToString();

                if (CurrentFile.Attributes.HasFlag(FileAttributes.ReadOnly))
                {
                    cbReadOnly.Checked = true;
                }
                if (CurrentFile.Attributes.HasFlag(FileAttributes.Hidden))
                {
                    cbHidden.Checked = true;
                }
                if (CurrentFile.Attributes.HasFlag(FileAttributes.System))
                {
                    cbSystem.Checked = true;
                }
                if (CurrentFile.Attributes.HasFlag(FileAttributes.Archive))
                {
                    cbArchive.Checked = true;
                }

                tbImageFormat.Text = ImageBinaryReader.GetMimeType(path);

                tbRawImageFormat.Text = image.RawFormat.Guid.ToString();

                tbWidth_1.Text = image.Size.Width.ToString() + " px";
                tbWidth_2.Text = (image.Size.Width / image.HorizontalResolution).ToString() + " inch";

                tbHeight_1.Text = image.Size.Height.ToString() + " px";
                tbHeight_2.Text = (image.Size.Height / image.VerticalResolution).ToString() + " inch";

                tbPixelsPerInch_1.Text = MathHelper.Average(image.HorizontalResolution, image.VerticalResolution).ToString();
                tbPixelsPerInch_2.Text = image.HorizontalResolution.ToString() + " x " + image.VerticalResolution.ToString();

                tbImageFlags.Text = image.Flags.ToString();

                tbBitFormat.Text = image.PixelFormat.ToString();

                PropertyItem[] propItems = image.PropertyItems;
                StringBuilder  sb        = new StringBuilder();
                int            count     = 0;
                foreach (PropertyItem propItem in propItems)
                {
                    sb.Append(((ExifPropertyTag)propItem.Id).ToString() + Environment.NewLine);
                    sb.Append("    ID: " + propItem.Id.ToString("") + Environment.NewLine);
                    sb.Append("    Type: " + ((ExifPropertyTagType)propItem.Type).ToString() + Environment.NewLine);
                    sb.Append("    Length: " + propItem.Len.ToString() + " bytes" + Environment.NewLine);

                    count++;
                }

                tbPropertyItems.Text = sb.ToString();
            }
        }