コード例 #1
0
ファイル: ImageTool.cs プロジェクト: femiosinowo/sssadl
        /// <summary>
        /// Flips the image.
        /// </summary>
        /// <param name="vertical">True if the flip is vertical, otherwise horizontal.</param>
        /// <param name="originalPathFile">Source file, could be the same as the change file.</param>
        /// <param name="changeImagePathFile">The file to receive the change.</param>
        /// <returns>True for success.</returns>
        public bool Flip(bool vertical, string originalPathFile, string changeImagePathFile)
        {
            bool bRet = false;

            if (null == originalPathFile) return false;
            if (null == changeImagePathFile) return false;

            if (originalPathFile.Length > 0)  // may have been set at creation, so not given
                m_originalFile = originalPathFile;

            // Fix slashes - never trust that they have done this.
            m_originalFile = m_originalFile.Replace('/', '\\').Replace("\\\\", "\\");
            changeImagePathFile = changeImagePathFile.Replace('/', '\\').Replace("\\\\", "\\");

            // use cximage library instead of .Net code
            if (m_originalFile != changeImagePathFile)
            {
                // copy file to new if needed
                StorageClient.Context.File.Copy(m_originalFile, changeImagePathFile, true);
                MakeWriteable(changeImagePathFile); // in case the original was readonly
            }
            ImageGalleryInterop.CImageResizerClass ig = new ImageGalleryInterop.CImageResizerClass();
            ig.FlipImageFile(changeImagePathFile, vertical ? 1 : 0);

            /*
            RotateFlipType rfAction = (vertical) ? RotateFlipType.RotateNoneFlipY : RotateFlipType.RotateNoneFlipX;

            System.Drawing.Image img = System.Drawing.Image.FromFile(m_originalFile);

            img.RotateFlip(rfAction);
            img.Save(changeImagePathFile);

            // Save for convenient use.
            m_width = img.Width;
            m_height = img.Height;
            img.Dispose();
            */
            m_localResultFile = changeImagePathFile;

            bRet = true;

            return bRet;
        }