コード例 #1
0
        public void ConvertToGrayScale(string SourceFileName, string DestFileName)
        {
            Bitmap bm = (Bitmap)Image.FromFile(SourceFileName);

            List <Bitmap> bitMaps = ConvertToGrayScale(bm, DestFileName, ResizeScale.HundredPercent);

            _fileSaver.TargetFileName = DestFileName;
            _fileSaver.SaveImages(bitMaps, DestFileName);
        }
コード例 #2
0
ファイル: TestHelper.cs プロジェクト: SamCui/ImageProcessor
        //Given a directory with images, SaveImages() copies them to another directory
        //has multiframe capability
        public void FileSaver_SaveImages(IFileSaver fileSaver)
        {
            fileSaver.SourceFilePath = @"c:\testImage\Source\OneColorTiff\";
            fileSaver.TargetFilePath = @"c:\testImage\Target\OneGrayScaleTiff\";

            foreach (var file in fileSaver.FilesToProcess)
            {
                Bitmap bitMap = (Bitmap)Image.FromFile(file);
                fileSaver.TargetFileName = Path.GetFileName(file);
                fileSaver.SaveImages(bitMap);
            }
        }
コード例 #3
0
        public void ConvertToGrayScale(string SourceFileName, string DestFileName)
        {
            List <Bitmap> bitMaps = new List <Bitmap>();

            using (MagickImageCollection images = new MagickImageCollection())
            {
                MagickReadSettings settings = new MagickReadSettings();
                images.Read(SourceFileName, settings);
                settings.FrameIndex = 0;            // First page
                settings.FrameCount = images.Count; // Number of pages
                int count = images.Count;

                foreach (MagickImage image in images)
                {
                    image.ColorType = ColorType.Grayscale;
                    image.Quantize();

                    var bm = image.ToBitmap();
                    bitMaps.Add(bm);

                    //image.Write(DestFileName + count.ToString() + ".tif");

                    ++count;
                }
            }

            _fileSaver.TargetFileName = DestFileName;
            _fileSaver.SaveImages(bitMaps, DestFileName);

            //Process proc = new Process
            //{
            //    StartInfo = new ProcessStartInfo

            //    {
            //        FileName = @"C:\Program Files\ImageMagick-6.8.6-Q16\convert.exe",
            //        Arguments = @"c:\testimage\target\onegrayscaletiff\*.tif c:\testimage\target\onegrayscaletiff\"+Guid.NewGuid().ToString() +".tif",
            //        UseShellExecute = false,
            //        RedirectStandardError = true,
            //        CreateNoWindow = true
            //    }
            //};

            //proc.Start();
        }