728x90
반응형
        #region SaveJPGFile
        /// <summary> 
        /// jpg 파일 저장하기 
        /// <summary>
        /// 비트맵 소스 
        /// 파일 경로 
        public static void SaveJPGFile(BitmapSource bitmapSource, string filePath) 
        {
            JpegBitmapEncoder jpgBitmapEncoder = new JpegBitmapEncoder();
            jpgBitmapEncoder.Frames.Add(BitmapFrame.Create(bitmapSource)); 

            using(FileStream fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write)) 
            {
                jpgBitmapEncoder.Save(fileStream); 
            } 
        } 
        #endregion

 

사용

ImageSource testImage = ..;
SaveJPGFile((BitmapSource)testImage , filePath);

반응형

+ Recent posts