当前位置: 首页>>代码示例>>C#>>正文


C# IFilter.Apply方法代码示例

本文整理汇总了C#中IFilter.Apply方法的典型用法代码示例。如果您正苦于以下问题:C# IFilter.Apply方法的具体用法?C# IFilter.Apply怎么用?C# IFilter.Apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFilter的用法示例。


在下文中一共展示了IFilter.Apply方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplyFilter

        private void ApplyFilter(IFilter filter)
        {
            try
            {
                // set wait cursor
                this.Cursor = Cursors.WaitCursor;

                // apply filter to the image
                Bitmap newImage = filter.Apply((Bitmap)this.Image.Image);

                if (backup == null)
                {
                    backup = this.Image.Image;
                }

                this.Image.Image = newImage;

            }
            catch (ArgumentException)
            {
                MessageBox.Show("Selected filter can not be applied to the image", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
开发者ID:dalinhuang,项目名称:appcollection,代码行数:27,代码来源:FormDetailedPic.cs

示例2: ApplyFilter

 // Apply filter on the image
 private static void ApplyFilter(IFilter filter, ref Bitmap image)
 {
     if (filter is IFilterInformation)
     {
         IFilterInformation filterInfo = (IFilterInformation)filter;
         if (!filterInfo.FormatTransalations.ContainsKey(image.PixelFormat))
         {
             if (filterInfo.FormatTransalations.ContainsKey(PixelFormat.Format24bppRgb))
             {
                 MessageBox.Show("The selected image processing routine may be applied to color image only.",
                                 "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 MessageBox.Show(
                     "The selected image processing routine may be applied to grayscale or binary image only.\n\nUse grayscale (and threshold filter if required) before.",
                     "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             return;
         }
     }
     try
     {
         // apply filter to the image
         image = filter.Apply(image);
     }
     catch
     {
         MessageBox.Show("Error occured applying selected filter to the image", "Error", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }
开发者ID:kapt-sino,项目名称:fingergraph,代码行数:33,代码来源:ProcessImage.cs

示例3: ApplyFilter

 private void ApplyFilter(IFilter filter)
 {
     Bitmap sourceImage = (Bitmap)ImagePanel.Image;
     // apply filter
     Bitmap filteredImage = null;
     if (sourceImage != null)
     {
         filteredImage = filter.Apply(sourceImage);
         // display filtered image
     }
     else { MessageBox.Show("No image was loaded.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
     ImagePanel.Image = filteredImage;
 }
开发者ID:JamesNgai,项目名称:WebcamProfiler,代码行数:13,代码来源:Form1.cs

示例4: RotateTest32bpp

        public static bool RotateTest32bpp(IFilter filter, Bitmap input, Bitmap output)
        {
            var itm = new ImageToMatrix();

            // Test directly
            Color[,] actual;
            itm.Convert(filter.Apply(input), out actual);

            Color[,] expected;
            itm.Convert(output, out expected);

            if (!actual.IsEqual(expected))
                return false;

            // Rotate and re-test
            var rotate = new RotateNearestNeighbor(90, false);
            input = rotate.Apply(input);
            output = rotate.Apply(output);

            itm.Convert(filter.Apply(input), out actual);
            itm.Convert(output, out expected);

            return actual.IsEqual(expected);
        }
开发者ID:CanerPatir,项目名称:framework,代码行数:24,代码来源:TestUtils.cs

示例5: ApplyFilter

        private void ApplyFilter(IFilter filter)
        {
            ClearCurrentImage();
            Bitmap filteredImage = null;

            try
            {
                filteredImage = filter.Apply(image.SourceImage);
            }
            catch (Exception exc) {
                MessageBox.Show(exc.ToString());
                return;
            }

            if (isFilterSet || isContrastBarSetValue || isBrightnesstBarSetValue)
            {
                pictureBox1.Image = image.SourceImage = filteredImage;
                painter.setContext(image.Context);
                isFilterSet = isContrastBarSetValue = isBrightnesstBarSetValue = false;
            }
            else
                pictureBox1.Image = filteredImage;
        }
开发者ID:schurik77799,项目名称:ImageProcesser-C-Sharp,代码行数:23,代码来源:Form1.cs

示例6: ApplyFilter

        // Apply filter on the image
        private void ApplyFilter(IFilter filter)
        {
            try
            {
                // set wait cursor
                this.Cursor = Cursors.WaitCursor;

                // apply filter to the image
                Bitmap newImage = filter.Apply(image);

                if (host.CreateNewDocumentOnChange)
                {
                    // open new image in new document
                    host.NewDocument(newImage);
                }
                else
                {
                    if (host.RememberOnChange)
                    {
                        // backup current image
                        if (backup != null)
                            backup.Dispose();

                        backup = image;
                    }
                    else
                    {
                        // release current image
                        image.Dispose();
                    }

                    image = newImage;

                    // update
                    UpdateNewImage();
                }
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Selected filter can not be applied to the image", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // restore cursor
                this.Cursor = Cursors.Default;
            }
        }
开发者ID:vebin,项目名称:PhotoBrushProject,代码行数:48,代码来源:ImageHandlerForm.cs

示例7: ApplyFilter

        public void ApplyFilter(IFilter filter)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                SetUndo();

                Bitmap newBitmap = filter.Apply(bitmap);
                if (cropped)
                    newBitmap = filter.Apply(zoomBitmap);

                if (toGrayscale)
                {
                    Bitmap tempBitmap = ColorToGrayscale(newBitmap);
                    bitmap = (Bitmap)tempBitmap.Clone();
                    tempBitmap.Dispose();
                    toGrayscale = false;
                }
                else
                {
                    bitmap = new Bitmap(newBitmap.Size.Width, newBitmap.Size.Height, PixelFormat.Format24bppRgb);
                    Graphics g = Graphics.FromImage(bitmap);
                    g.DrawImage(newBitmap, new Point(0, 0));
                    g.Dispose();
                }
                newBitmap.Dispose();
                MenuItemUndo.Enabled = true;
                toolStripButtonUndo.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "SPixel", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
            this.imageDisplay.Invalidate();
        }
开发者ID:xsysfan,项目名称:SPixel,代码行数:40,代码来源:MainForm.cs

示例8: ApplyFilter

 private Bitmap ApplyFilter(IFilter filter)
 {
     filteredImage = filter.Apply(sourceImage);
     return filteredImage;
 }
开发者ID:EricBlack,项目名称:web-automation,代码行数:5,代码来源:Main.cs

示例9: ApplyFilter

 public static HtmlDocument ApplyFilter(this HtmlDocument doc, IFilter filter)
 {
     filter.Apply(doc);
     return doc;
 }
开发者ID:andriniaina,项目名称:playground,代码行数:5,代码来源:IFilter.cs

示例10: ApplyFilter

 // Apply filter to the source image and show the filtered image
 private void ApplyFilter( IFilter filter )
 {
     ClearCurrentImage( );
     // apply filter
     filteredImage = filter.Apply( sourceImage );
     // display filtered image
     pictureBox.Image = filteredImage;
 }
开发者ID:nagyistoce,项目名称:Neuroflow,代码行数:9,代码来源:MainForm.cs

示例11: ApplyFilter

        // Apply filter on the image
        private void ApplyFilter( IFilter filter )
        {
            if ( filter is IFilterInformation )
            {
                IFilterInformation filterInfo = (IFilterInformation) filter;

                if ( !filterInfo.FormatTransalations.ContainsKey( image.PixelFormat ) )
                {
                    if ( filterInfo.FormatTransalations.ContainsKey( PixelFormat.Format24bppRgb ) )
                    {
                        MessageBox.Show( "The selected image processing routine may be applied to color image only.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
                    }
                    else
                    {
                        MessageBox.Show( "The selected image processing routine may be applied to grayscale or binary image only.\n\nUse grayscale (and threshold filter if required) before.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
                    }
                    return;
                }
            }

            try
            {
                // set wait cursor
                this.Cursor = Cursors.WaitCursor;

                // apply filter to the image
                Bitmap newImage = filter.Apply( image );

                if ( host.CreateNewDocumentOnChange )
                {
                    // open new image in new document
                    host.NewDocument( newImage );
                }
                else
                {
                    if ( host.RememberOnChange )
                    {
                        // backup current image
                        if ( backup != null )
                            backup.Dispose( );

                        backup = image;
                    }
                    else
                    {
                        // release current image
                        image.Dispose( );
                    }

                    image = newImage;

                    // update
                    UpdateNewImage( );
                }
            }
            catch
            {
                MessageBox.Show( "Error occured applying selected filter to the image", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
            }
            finally
            {
                // restore cursor
                this.Cursor = Cursors.Default;
            }
        }
开发者ID:kapt-sino,项目名称:fingergraph,代码行数:66,代码来源:ImageDoc.cs

示例12: Apply

 public static Bitmap Apply(this Bitmap bitmap, IFilter filter)
 {
     return filter.Apply(bitmap);
 }
开发者ID:MrHayato,项目名称:PhotoCache,代码行数:4,代码来源:ImageExtensions.cs

示例13: ApplyFilter

 public void ApplyFilter(IFilter filter)
 {
     filter.Apply(this._bitmap);
 }
开发者ID:RamanBut-Husaim,项目名称:MiSOI,代码行数:4,代码来源:ImageProcessor.cs


注:本文中的IFilter.Apply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。