本文整理汇总了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;
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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();
}
示例8: ApplyFilter
private Bitmap ApplyFilter(IFilter filter)
{
filteredImage = filter.Apply(sourceImage);
return filteredImage;
}
示例9: ApplyFilter
public static HtmlDocument ApplyFilter(this HtmlDocument doc, IFilter filter)
{
filter.Apply(doc);
return doc;
}
示例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;
}
示例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;
}
}
示例12: Apply
public static Bitmap Apply(this Bitmap bitmap, IFilter filter)
{
return filter.Apply(bitmap);
}
示例13: ApplyFilter
public void ApplyFilter(IFilter filter)
{
filter.Apply(this._bitmap);
}