コード例 #1
0
 public SlicePicker(IFilter grayscaleFilter, IInPlaceFilter edgeDetectionFilter, SliceRatingCalculator ratingCalculator, ThumbnailGeneratorUtilities thumbnailGeneratorUtilities)
 {
     this.grayscaleFilter = grayscaleFilter;
      this.edgeDetectionFilter = edgeDetectionFilter;
      this.ratingCalculator = ratingCalculator;
      this.thumbnailGeneratorUtilities = thumbnailGeneratorUtilities;
 }
コード例 #2
0
 public SlicePicker(IFilter grayscaleFilter, IInPlaceFilter edgeDetectionFilter, SliceRatingCalculator ratingCalculator, ThumbnailGeneratorUtilities thumbnailGeneratorUtilities)
 {
     this.grayscaleFilter             = grayscaleFilter;
     this.edgeDetectionFilter         = edgeDetectionFilter;
     this.ratingCalculator            = ratingCalculator;
     this.thumbnailGeneratorUtilities = thumbnailGeneratorUtilities;
 }
コード例 #3
0
 public Filter(FilterManager filterManager, string id, string name, double value, IInPlaceFilter filter)
 {
     this.filterManager  = filterManager;
     this.Id             = id;
     this.Name           = name;
     this.value          = value;
     this.iInPlaceFilter = filter;
 }
コード例 #4
0
ファイル: ImageFitler.cs プロジェクト: hxshandle/PrintCat
        public void ExecuteFitler(IInPlaceFilter filter)
        {
            BitmapSource bitmapSource = currentImageHandler.GetCropedImageSource().Clone();
              Bitmap bitmap = ImageHelper.BitmapFromSource(bitmapSource);

              filter.ApplyInPlace(bitmap);
              BitmapSource newBitmapSouce = ImageHelper.ConvertBitmap(bitmap);
              this.currentImageHandler.CurrentImage.Source = newBitmapSouce;
        }
コード例 #5
0
        public void ApplyInPlace(BitmapData imageData)
        {
            BeforeApplyingFilter(imageData);
            IInPlaceFilter inPlaceFilter = filter as IInPlaceFilter;

            if (inPlaceFilter != null)
            {
                inPlaceFilter.ApplyInPlace(imageData);
            }
            FilterApplied(imageData);
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: xsysfan/SPixel
 public void ApplyFilterInPlace(IInPlaceFilter filter)
 {
     try
     {
         SetUndo();
         filter.ApplyInPlace(bitmap);
         MenuItemUndo.Enabled = true;
         toolStripButtonUndo.Enabled = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "SPixel", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     this.imageDisplay.Invalidate();
 }
コード例 #7
0
 //Easier to chain filters
 public static Bitmap ApplyInPlace(this Bitmap bitmap, IInPlaceFilter filter)
 {
     filter.ApplyInPlace(bitmap);
     return bitmap;
 }
コード例 #8
0
        private void Repair(ImageEditor repair, ImageProcessingArgs args)
        {
            // Increment the internal Page Index for the current ImageConversionOptions object
            args.Options.PageIndex++;

            // Build the filename part based on the PageIndex (will be persisted across calls so long as the same Options are used)
            var filePart = String.Format("{0:000}.tif", args.Options.PageIndex);

            // Create the Page object
            var page = new PageInfo()
            {
                FileName     = Path.Combine(args.Options.SaveToPath, filePart),
                RelativePath = Path.Combine(args.Options.RelativePath, filePart),
                Width        = repair.Image.Width,
                Height       = repair.Image.Height
            };

            if (!repair.Image.IsBitonal())
            {
                // Not already bitonal, so process as necessary
                switch (args.Options.BitDepth)
                {
                case 1:
                    if (args.Options.BinarisationAlgorithm == BinarisationAlgorithm.Default || args.Options.BinarisationAlgorithm == BinarisationAlgorithm.ClearImage)
                    {
                        repair.AdvancedBinarize(args.Options.Resolution);
                    }
                    else
                    {
                        // Source image must be grayscaled first
                        repair.ToGrayscale();

                        // Using an unmanaged image we will operate directly on the source images memory
                        using (UnmanagedImage image = new UnmanagedImage(repair.Image.Buffer, repair.Width, repair.Height, repair.Image.LineBytes, PixelFormat.Format8bppIndexed))
                        {
                            IInPlaceFilter filter = null;

                            if (args.Options.BinarisationAlgorithm == BinarisationAlgorithm.OtsuThreshold)
                            {
                                filter = new OtsuThreshold();
                            }
                            else if (args.Options.BinarisationAlgorithm == BinarisationAlgorithm.FloydSteinbergDither)
                            {
                                filter = new FloydSteinbergDithering();
                            }
                            else
                            {
                                filter = new BradleyLocalThresholding();
                            }

                            filter.ApplyInPlace(image);
                        }

                        // Image is still in 8 bit format (but is bitonal) so we need to convert to a 1 bit image
                        repair.ToBitonal();
                    }

                    break;

                case 8:
                    repair.ToGrayscale();
                    break;
                }

                // Set the Resolution
                repair.Image.HorzDpi = args.Options.Resolution;
                repair.Image.VertDpi = args.Options.Resolution;
            }
            else
            {
                // Is already bitonal, so quite possibly a fax
                repair.FaxStandardToFine();

                // Remove the Fax Header if exists
                if (args.Options.RemoveFaxHeader)
                {
                    repair.FaxRemoveHeader();
                }
            }

            // Perform Auto Deskew
            if (args.Options.AutoDeskew.GetValueOrDefault())
            {
                page.Skew = repair.AutoDeskew();
            }

            // Perform Auto Rotate
            if (args.Options.AutoRotate.GetValueOrDefault())
            {
                page.Rotation = repair.AutoRotate();
            }

            // Check if the image is blank and store with the Page object
            page.IsBlank = repair.IsBlankImage();

            // Setup the image save options
            if (repair.Image.IsBitonal())
            {
                repair.Image.pComprBitonal = EComprBitonal.citbCCITTFAX4;
            }
            else
            {
                repair.Image.pComprColor = EComprColor.citcJPEG;
                repair.Image.JpegQuality = 85;
            }

            // Save the image
            repair.Image.SaveAs(page.FileName, EFileFormat.ciEXT);

            // Add the page to the collection
            args.Pages.Add(page);
        }