Beispiel #1
0
        public static bool GetRotInfo(FileInfo fi, out ushort rotateme)
        {
            bool gotRotInfo = false;

            rotateme = 1;
            FIBITMAP?dibNull = GetJPGImageHandle(fi);

            if (dibNull != null)
            {
                FIBITMAP      dib       = (FIBITMAP)dibNull;
                var           iMetadata = new ImageMetadata(dib);
                MetadataModel exifMain  = iMetadata[FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN];
                if (exifMain != null)
                {
                    MetadataTag orientationTag = exifMain.GetTag("Orientation");
                    if (orientationTag != null)
                    {
                        var rotInfo = (ushort[])orientationTag.Value;
                        rotateme   = rotInfo[0];
                        gotRotInfo = true;
                    }
                }
                CleanUpResources(dib);
            }
            return(gotRotInfo);
        }
Beispiel #2
0
        /// <summary>
        /// get the rotation info
        /// </summary>
        /// <param name="dib"></param>
        /// <returns></returns>
        public static ushort GetRotateInfo(FIBITMAP dib)
        {
            ushort        rotateme  = 1;
            var           iMetadata = new ImageMetadata(dib);
            MetadataModel exifMain  = iMetadata[FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN];

            if (exifMain != null)
            {
                MetadataTag orientationTag = exifMain.GetTag("Orientation");
                if (orientationTag != null)
                {
                    var rotInfo = (ushort[])orientationTag.Value;
                    if (rotInfo != null && rotInfo.Length > 0)
                    {
                        rotateme = rotInfo[0];
                    }
                }
            }
            return(rotateme);
        }
Beispiel #3
0
        /// <summary>
        /// set the rotation info
        /// </summary>
        /// <remarks>FREEIMAGE (until 3.11) does not support writing of metadata!!!!!!!!!</remarks>
        /// <param name="dib"></param>
        /// <param name="rotInfo"></param>
        /// <returns>if the value was changed</returns>
        public static bool SetRotateInfo(FIBITMAP dib, ushort rotInfo)
        {
            bool          changed   = false;
            var           iMetadata = new ImageMetadata(dib);
            MetadataModel exifMain  = iMetadata[FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN];

            if (exifMain != null)
            {
                MetadataTag orientationTag = exifMain.GetTag("Orientation");
                if (orientationTag != null)
                {
                    var nuval = new[] { rotInfo };
                    if (orientationTag.Value != nuval)
                    {
                        orientationTag.SetValue(nuval);
                        changed = true;
                    }
                }
            }
            return(changed);
        }