Ejemplo n.º 1
0
        private void ReconstructExifInfoCache()
        {
            OnChanging();
            ++suppressChangeEvents;

            exifIdToExifInfo.Clear();

            string[] exifKeys = GetKeys(ExifSectionName);
            string[] piBlobs  = new string[exifKeys.Length];

            for (int i = 0; i < exifKeys.Length; ++i)
            {
                piBlobs[i] = GetValue(ExifSectionName, exifKeys[i]);
                this.RemoveValue(ExifSectionName, exifKeys[i]);
            }

            foreach (string piBlob in piBlobs)
            {
                PropertyItem pi = PdnGraphics.DeserializePropertyItem(piBlob);
                AddExifValues(new PropertyItem[] { pi });
            }

            --suppressChangeEvents;
            OnChanged();
        }
Ejemplo n.º 2
0
        public static void LoadProperties(Image dstImage, Document srcDoc)
        {
            Bitmap asBitmap = dstImage as Bitmap;

            if (asBitmap != null)
            {
                // Sometimes GDI+ does not honor the resolution tags that we
                // put in manually via the EXIF properties.
                float dpiX;
                float dpiY;

                switch (srcDoc.DpuUnit)
                {
                case MeasurementUnit.Centimeter:
                    dpiX = (float)Document.DotsPerCmToDotsPerInch(srcDoc.DpuX);
                    dpiY = (float)Document.DotsPerCmToDotsPerInch(srcDoc.DpuY);
                    break;

                case MeasurementUnit.Inch:
                    dpiX = (float)srcDoc.DpuX;
                    dpiY = (float)srcDoc.DpuY;
                    break;

                default:
                case MeasurementUnit.Pixel:
                    dpiX = 1.0f;
                    dpiY = 1.0f;
                    break;
                }

                try
                {
                    asBitmap.SetResolution(dpiX, dpiY);
                }

                catch (Exception)
                {
                    // Ignore error
                }
            }

            Metadata metaData = srcDoc.Metadata;

            foreach (string key in metaData.GetKeys(Metadata.ExifSectionName))
            {
                string       blob = metaData.GetValue(Metadata.ExifSectionName, key);
                PropertyItem pi   = PdnGraphics.DeserializePropertyItem(blob);

                try
                {
                    dstImage.SetPropertyItem(pi);
                }

                catch (ArgumentException)
                {
                    // Ignore error: the image does not support property items
                }
            }
        }
Ejemplo n.º 3
0
        public static void LoadProperties(Image dstImage, Document srcDoc, Func <System.Drawing.Imaging.PropertyItem, bool> selectorFn)
        {
            Bitmap bitmap = dstImage as Bitmap;

            if (bitmap != null)
            {
                float dpuX;
                float dpuY;
                switch (srcDoc.DpuUnit)
                {
                case MeasurementUnit.Inch:
                    dpuX = (float)srcDoc.DpuX;
                    dpuY = (float)srcDoc.DpuY;
                    break;

                case MeasurementUnit.Centimeter:
                    dpuX = (float)Document.DotsPerCmToDotsPerInch(srcDoc.DpuX);
                    dpuY = (float)Document.DotsPerCmToDotsPerInch(srcDoc.DpuY);
                    break;

                default:
                    dpuX = 1f;
                    dpuY = 1f;
                    break;
                }
                try
                {
                    bitmap.SetResolution(dpuX, dpuY);
                }
                catch (Exception)
                {
                }
            }
            Metadata metadata = srcDoc.Metadata;

            foreach (string str in metadata.GetKeys("$exif"))
            {
                System.Drawing.Imaging.PropertyItem arg = PdnGraphics.DeserializePropertyItem(metadata.GetValue("$exif", str));
                if (selectorFn(arg))
                {
                    try
                    {
                        dstImage.SetPropertyItem(arg);
                    }
                    catch (ArgumentException)
                    {
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static void LoadProperties(Image dstImage, Document srcDoc)
        {
            Metadata metaData = srcDoc.Metadata;

            foreach (string key in metaData.GetKeys(Metadata.ExifSectionName))
            {
                string       blob = metaData.GetValue(Metadata.ExifSectionName, key);
                PropertyItem pi   = PdnGraphics.DeserializePropertyItem(blob);

                try
                {
                    dstImage.SetPropertyItem(pi);
                }

                catch (ArgumentException)
                {
                    // Ignore error: the image does not support property items
                }
            }
        }