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


C# FilterEffect类代码示例

本文整理汇总了C#中FilterEffect的典型用法代码示例。如果您正苦于以下问题:C# FilterEffect类的具体用法?C# FilterEffect怎么用?C# FilterEffect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: EnhanceAsync

        public async Task<EnhanceResult> EnhanceAsync(Frame frame)
        {
            using (var bitmap = new Bitmap(new Windows.Foundation.Size(frame.Dimensions.Width, frame.Dimensions.Height), Internal.Utilities.FrameFormatToColorMode(frame.Format), frame.Pitch, frame.Buffer.AsBuffer()))
            using (var source = new BitmapImageSource(bitmap))
            using (var effect = new FilterEffect(source))
            using (var renderer = new BitmapRenderer(effect))
            {
                effect.Filters = new List<IFilter>()
                {
                    new ContrastFilter(0.5)
                };

                using (var newBitmap = new Bitmap(new Windows.Foundation.Size(frame.Dimensions.Width, frame.Dimensions.Height), Internal.Utilities.FrameFormatToColorMode(frame.Format)))
                {
                    await effect.GetBitmapAsync(newBitmap, OutputOption.PreserveAspectRatio);

                    return new EnhanceResult()
                    {
                        Frame = new Frame()
                        {
                            Buffer = newBitmap.Buffers[0].Buffer.ToArray(),
                            Pitch = newBitmap.Buffers[0].Pitch,
                            Format = frame.Format,
                            Dimensions = newBitmap.Dimensions
                        }
                    };
                }
            }
        }
开发者ID:NathanAUS,项目名称:optical-reader,代码行数:29,代码来源:BasicEnhancer.cs

示例2: Process

 public void Process(Bitmap input, Bitmap output, TimeSpan time)
 {
     var effect = new FilterEffect();
     effect.Filters = new IFilter[]{ new WatercolorFilter() };
     effect.Source = new BitmapImageSource(input);
     var renderer = new BitmapRenderer(effect, output);
     renderer.RenderAsync().AsTask().Wait(); // Async calls must run sync inside Process()
 }
开发者ID:gtarbell,项目名称:VideoEffect,代码行数:8,代码来源:BitmapEffect.cs

示例3: RecipeCSharpFilter

        public RecipeCSharpFilter(IImageProvider source, double factor)
            : base(source)
        {
            effect = new FilterEffect(source);
            effect.Filters = new IFilter[]{new CSharp.MyFilter (factor)};

             SetPipelineBeginEnd(effect, effect);
        }
开发者ID:Nokia-Developer-Community-Projects,项目名称:wp8-sample,代码行数:8,代码来源:RecipeCSharpFilter.cs

示例4: NormalizeAsync

        public async Task<NormalizeResult> NormalizeAsync(Frame frame, Windows.Foundation.Rect area, double rotation)
        {
            using (var bitmap = new Bitmap(frame.Dimensions, Internal.Utilities.FrameFormatToColorMode(frame.Format), frame.Pitch, frame.Buffer.AsBuffer()))
            using (var source = new BitmapImageSource(bitmap))
            using (var effect = new FilterEffect(source))
            using (var renderer = new BitmapRenderer(effect))
            {
                effect.Filters = new List<IFilter>()
                {
                    new ReframingFilter(area, -rotation)
                };

                using (var newBitmap = new Bitmap(new Windows.Foundation.Size(area.Width, area.Height), Internal.Utilities.FrameFormatToColorMode(frame.Format)))
                {
                    await effect.GetBitmapAsync(newBitmap, OutputOption.PreserveAspectRatio);

                    return new NormalizeResult()
                    {
                        Frame = new Frame()
                        {
                            Buffer = newBitmap.Buffers[0].Buffer.ToArray(),
                            Pitch = newBitmap.Buffers[0].Pitch,
                            Format = frame.Format,
                            Dimensions = newBitmap.Dimensions
                        },
                        Translate = new Func<Windows.Foundation.Point, Windows.Foundation.Point>((normalizedPoint) =>
                        {
                            var rotationRadians = -rotation / 360.0 * 2.0 * Math.PI;
                            var sin = Math.Sin(rotationRadians);
                            var cos = Math.Cos(rotationRadians);
                            var origoX = area.Width / 2.0;
                            var origoY = area.Height / 2.0;

                            // Translate point to origo before rotation
                            var ox = normalizedPoint.X - origoX;
                            var oy = normalizedPoint.Y - origoY;

                            // Move area to origo, calculate new point positions, restore area location and add crop margins
                            var x = ox * cos - oy * sin;
                            var y = ox * sin + oy * cos;

                            // Translate point back to area after rotation
                            x = x + origoX;
                            y = y + origoY;

                            // Add margins from original uncropped frame
                            x = x + area.X;
                            y = y + area.Y;

                            return new Windows.Foundation.Point(x, y);
                        })
                    };
                }
            }
        }
开发者ID:NathanAUS,项目名称:optical-reader,代码行数:55,代码来源:BasicNormalizer.cs

示例5: RecipeDaisyChain

        public RecipeDaisyChain(IImageProvider source, double factor)
            : base(source)
        {
            effect_1 = new HdrEffect(source);
            effect_2 = new FilterEffect(effect_1);

            if(factor>2) factor = 2;
            effect_2.Filters = new IFilter[] { new HueSaturationFilter(-1 + factor, 0), new LomoFilter() };

            SetPipelineBeginEnd(effect_1, effect_2);
        }
开发者ID:Nokia-Developer-Community-Projects,项目名称:wp8-sample,代码行数:11,代码来源:RecipeDaisyChain.cs

示例6: RecipeCPPFilter

        public RecipeCPPFilter(IImageProvider source, double factor)
            : base(source)
        {
            filter = new CPP.MyFilter(factor);
            delegatingFilter = new DelegatingFilter(filter);

            effect = new FilterEffect(source);
            effect.Filters = new IFilter[] { delegatingFilter };

             SetPipelineBeginEnd(effect, effect);
        }
开发者ID:Nokia-Developer-Community-Projects,项目名称:wp8-sample,代码行数:11,代码来源:RecipeCPPFilter.cs

示例7: RenderEmptyCustomFilter

        public async Task RenderEmptyCustomFilter()
        {
            var customFilter = new EmptyCustomFilter();

            using (var source = KnownImages.MikikoLynn.ImageSource)
            using (var filterEffect = new FilterEffect(source) { Filters = new[] { customFilter } })
            using (var renderer = new JpegRenderer(filterEffect))
            {
                var buffer = await renderer.RenderAsync();
                ImageResults.Instance.SaveToPicturesLibrary(buffer);
            }
        }
开发者ID:nagyistoce,项目名称:Lumia-Imaging-SDK-Extras,代码行数:12,代码来源:CustomFiltersCxTests.cs

示例8: Render

        public async static Task<WriteableBitmap> Render(WriteableBitmap actualImage, List<IFilter> filters)
        {
            var bitmap = actualImage.AsBitmap();
            BitmapImageSource bitmapSource = new BitmapImageSource(bitmap);

            FilterEffect effects = new FilterEffect(bitmapSource);

            effects.Filters = filters;
            WriteableBitmapRenderer renderer = new WriteableBitmapRenderer(effects, actualImage);

            return await renderer.RenderAsync();

        }
开发者ID:msincenselee,项目名称:win8-xaml-sdk,代码行数:13,代码来源:NokiaRenderer.cs

示例9: applyFilter

        public async Task applyFilter(byte[] imageData, WriteableBitmap processedBitmap, List<IFilter> _components)
        {   
            MemoryStream ms = new MemoryStream(imageData);
            var source = new StreamImageSource(ms);
            var effect = new FilterEffect(source);
            var renderer = new WriteableBitmapRenderer(effect, processedBitmap);

            var filters = new List<IFilter>();
            filters = _components;

            effect.Filters = filters;
            await renderer.RenderAsync();
            processedBitmap.Invalidate();
        }
开发者ID:jozhang1,项目名称:PhotoProcess_0.1,代码行数:14,代码来源:Filter.cs

示例10: HighpassEffect

        /// <summary>
        /// Constructs a high pass effect with the specified parameters.
        /// </summary>
        /// <param name="kernelSize">The size of the filter kernel. A larger size preserves more of lower frequencies.</param>
        /// <param name="isGrayscale">True if the highpass effect should give a grayscale result. Otherwise the individual R, G, B channels are treated separately.</param>
        /// <param name="downscaleDivisor">How much to downscale the image to reduce the cost of the internal blur operation, trading speed for some fidelity. Suitable value depends on the kernelSize.</param>
        public HighpassEffect(uint kernelSize, bool isGrayscale = false, uint downscaleDivisor = 1)
        {
            m_kernelSize = kernelSize;
            m_downscaleDivisor = downscaleDivisor;
            m_isGrayscale = isGrayscale;
            
            if (m_downscaleDivisor > 1)
            {
                m_downscaleFilterEffect = new FilterEffect(/*source*/) { Filters = new IFilter[] { new ScaleFilter(1.0 / m_downscaleDivisor) } };
                m_downscaleCachingEffect = new CachingEffect(m_downscaleFilterEffect);

                int blurKernelSize = Math.Max(1, (int)(3.0 * m_kernelSize / m_downscaleDivisor));

                m_blurFilter = new BlurFilter(blurKernelSize);
                m_blurredFilterEffect = new FilterEffect(m_downscaleCachingEffect)
                {
                    Filters = new IFilter[] { m_blurFilter }
                };

                m_highPassBlendEffect = new BlendEffect( /*source*/)
                {
                    ForegroundSource = m_blurredFilterEffect,
                    BlendFunction = BlendFunction.SignedDifference
                };
            }
            else
            {
                int blurKernelSize = Math.Max(1, (int)(3.0 * m_kernelSize));

                m_blurFilter = new BlurFilter(blurKernelSize);
                m_blurredFilterEffect = new FilterEffect(/*source*/)
                {
                    Filters = new IFilter[] { m_blurFilter }
                };

                m_highPassBlendEffect = new BlendEffect( /*source*/)
                {
                    ForegroundSource = m_blurredFilterEffect,
                    BlendFunction = BlendFunction.SignedDifference
                };
            }
                 
            if (m_isGrayscale)
            {
                m_highPassGrayscaleFilterEffect = new FilterEffect(m_highPassBlendEffect)
                {     
                    Filters = new IFilter[] { new GrayscaleFilter() }
                };
            }
        }
开发者ID:nagyistoce,项目名称:Lumia-Imaging-SDK-Extras,代码行数:56,代码来源:HighpassEffect.cs

示例11: HslAdjustmentEffect

        public HslAdjustmentEffect()
        {
            m_filterEffect = new FilterEffect();

            m_saturation = new int[ChannelCount];
            m_lightness = new int[ChannelCount];

            m_hslFilter = new HueSaturationLightnessFilter();
            m_masterLightnessCurvesFilter = new CurvesFilter(m_masterLightnessCurve);

            m_masterLightnessCurve = new Curve(CurveInterpolation.Linear);
            m_tempCurve = new Curve(CurveInterpolation.Linear);

            m_filtersWithoutMasterLightness = new IFilter[] { m_hslFilter };
            m_allFilters = new IFilter[] { m_hslFilter, m_masterLightnessCurvesFilter };
        }
开发者ID:nagyistoce,项目名称:Lumia-Imaging-SDK-Extras,代码行数:16,代码来源:HslAdjustmentEffect.cs

示例12: RenderProviderAndEffect

		public async Task RenderProviderAndEffect()
		{
			var tile = KnownImages.MikikoLynn;

			using (var tileSource = tile.ImageSource)
			using (var source = new RepeatedTileImageSource(new Size(3048, 3048), tileSource, tile.Size))
			using (var filterEffect = new FilterEffect(source))
			using (var renderer = new JpegRenderer(filterEffect))
			{
				filterEffect.Filters = new[] { new GrayscaleFilter() };

				var buffer = await renderer.RenderAsync();

				ImageResults.Instance.SaveToPicturesLibrary(buffer, "RepeatedTileGrayscaleRender.jpg");
			}
		}
开发者ID:nagyistoce,项目名称:Lumia-Imaging-SDK-Extras,代码行数:16,代码来源:RepeatedTileImageSourceTest.cs

示例13: RenderProviderCreatedFromTileSource

		public async Task RenderProviderCreatedFromTileSource()
		{
			var tile = KnownImages.MikikoLynn;

			using (var tileSource = tile.ImageSource)
			using (var source = await RepeatedTileImageSource.CreateFromTileSource(new Size(4048, 4048), tileSource))
			using (var filterEffect = new FilterEffect(source))
			using (var renderer = new JpegRenderer(filterEffect))
			{
				filterEffect.Filters = new[] { new CartoonFilter() };

				var buffer = await renderer.RenderAsync();

				ImageResults.Instance.SaveToPicturesLibrary(buffer, "RepeatedTileCartoonRender.jpg");
			}
		}
开发者ID:nagyistoce,项目名称:Lumia-Imaging-SDK-Extras,代码行数:16,代码来源:RepeatedTileImageSourceTest.cs

示例14: ApplyFilter

        private async Task ApplyFilter(ImageFilter imageFilter, Image image)
        {
            FilterEffect effect = new FilterEffect(new BitmapImageSource(ImageToFilter.AsBitmap()));
            effect.Filters = new IFilter[] { imageFilter.Filter };

            WriteableBitmap temporaryImage = new WriteableBitmap(MainPage.ImageToFilter);
            WriteableBitmapRenderer renderer = new WriteableBitmapRenderer(effect, temporaryImage);
            await renderer.RenderAsync();

            image.Source = temporaryImage;
            // Here we create a new EditingSession based on our selected image and add the selected filter to it
            // After the picture gets rendered to our delivered image
            //editingSession = new EditingSession(ImageToFilter.AsBitmap());
            //editingSession.AddFilter(imageFilter.Filter);
            //await editingSession.RenderToImageAsync(image, OutputOption.PreserveAspectRatio);
        }
开发者ID:robinmanuelthiel,项目名称:Instagram-In-One-Hour,代码行数:16,代码来源:MainPage.xaml.cs

示例15: FilterView_Loaded

        async void FilterView_Loaded(object sender, RoutedEventArgs e)
        {
            // To edit a picture with the Nokia Imaging SDK we need a FilterEffect
            // Such a filter session is based on an image and one or more filters
            // Here we create a new FilterEffect that is based on our on the MainPage selected image
            FilterEffect effect = new FilterEffect(new BitmapImageSource(MainPage.ImageToFilter.AsBitmap()));


            // Add the filter we want to offer to our users to the list
            // You can find an overview of mor filters here: http://developer.nokia.com/Resources/Library/Lumia/#!nokia-imaging-sdk.html
            filterList = new List<ImageFilter>();
            filterList.Add(new ImageFilter("Cartoon", new CartoonFilter(true)));
            filterList.Add(new ImageFilter("Antique", new AntiqueFilter()));
            filterList.Add(new ImageFilter("Color Boost", new ColorBoostFilter(2)));
            filterList.Add(new ImageFilter("Gray Scale", new GrayscaleFilter()));
            filterList.Add(new ImageFilter("Negative", new NegativeFilter()));
            filterList.Add(new ImageFilter("Sktech", new SketchFilter(SketchMode.Color)));
            filterList.Add(new ImageFilter("Mirror", new MirrorFilter()));

            // Here we add a new PivotItem for every filter we want to use
            // So the user can flip through all offered filters in the PivotControl of this page
            foreach (ImageFilter imageFilter in filterList)
            {
                // Create a new Image that we can add to each PivotItem later as a preview of the filter
                Image pivotItemImage = new Image();
                pivotItemImage.Width = 400;
                pivotItemImage.Height = 400;

                // Create the PivotItem that we want to add and set its content to the preview image we created above
                PivotItem pivotItem = new PivotItem();
                pivotItem.Header = imageFilter.Name;
                pivotItem.Content = pivotItemImage;

                // Now we add the created PivotItem to the PivotControl on this page
                FilterPivot.Items.Add(pivotItem);

                // Add the current filter
                effect.Filters = new IFilter[] { imageFilter.Filter };

                // Last we need to render the preview image
                WriteableBitmap temporaryImage = new WriteableBitmap(MainPage.ImageToFilter);
                WriteableBitmapRenderer renderer = new WriteableBitmapRenderer(effect, temporaryImage);
                await renderer.RenderAsync();
              
                pivotItemImage.Source = temporaryImage;
            }
        }
开发者ID:robinmanuelthiel,项目名称:Instagram-In-One-Hour,代码行数:47,代码来源:FilterSelectorView.xaml.cs


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