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


C# Util.FastBitmap类代码示例

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


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

示例1: ApplyFilter

        /// <summary>
        /// Applies the filter to the specified <paramref name="bitmap"/>. This method
        /// first calls <see cref="ImageReplacementFilter.GetDestinationDimensions(FastBitmap, out Int32, out Int32)" />
        /// to calculate the size of the destination image. Then it calls
        /// <see cref="ImageReplacementFilter.ApplyFilter(FastBitmap, DrawingContext, int, int)" /> 
        /// which is where the overridden class implements its filter algorithm.
        /// </summary>
        /// <param name="bitmap">
        /// Image to apply the <see cref="ImageReplacementFilter" /> to.
        /// </param>
        public override sealed void ApplyFilter(FastBitmap bitmap)
        {
            OnBeginApplyFilter(bitmap);

            // get destination dimensions
            int width, height;
            bool shouldContinue = GetDestinationDimensions(bitmap, out width, out height);
            if (!shouldContinue)
                return;

            DrawingVisual dv = new DrawingVisual();
            ConfigureDrawingVisual(bitmap, dv);

            DrawingContext dc = dv.RenderOpen();

            ApplyFilter(bitmap, dc, width, height);
            dc.Close();

            RenderTargetBitmap rtb = RenderTargetBitmapUtility.CreateRenderTargetBitmap(width, height);
            rtb.Render(dv);
            FastBitmap destination = new FastBitmap(rtb);

            // copy metadata
            // TODO
            /*foreach (PropertyItem propertyItem in bitmap.InnerBitmap.PropertyItems)
                destination.InnerBitmap.SetPropertyItem(propertyItem);*/

            // set new image
            bitmap.InnerBitmap = destination.InnerBitmap;

            OnEndApplyFilter();
        }
开发者ID:jaytwo,项目名称:dynamic-image,代码行数:42,代码来源:ImageReplacementFilter.cs

示例2: GetEffect

 protected override Effect GetEffect(FastBitmap source)
 {
     return new ContrastAdjustmentEffect
     {
         Level = (Level + 100) / 40.0
     };
 }
开发者ID:sitdap,项目名称:dynamic-image,代码行数:7,代码来源:ContrastAdjustmentFilter.cs

示例3: CreateImage

        protected override sealed void CreateImage()
        {
            base.CreateImage();

            Rect bounds = new Rect(StrokeWidth / 2, StrokeWidth / 2,
                CalculatedWidth - StrokeWidth,
                CalculatedHeight - StrokeWidth);
            Brush brush = Fill.GetBrush();

            PointCollection points = GetPoints(bounds);
            PathGeometry geometry = CanonicalSplineHelper.CreateSpline(points, Roundness / 100.0, null, true, true, 0.25);

            Pen pen = GetPen();

            DrawingVisual dv = new DrawingVisual();
            DrawingContext dc = dv.RenderOpen();

            // Draw polygon.
            dc.DrawGeometry(brush, pen, geometry);

            dc.Close();

            RenderTargetBitmap rtb = RenderTargetBitmapUtility.CreateRenderTargetBitmap(CalculatedWidth, CalculatedHeight);
            rtb.Render(dv);
            Bitmap = new FastBitmap(rtb);
        }
开发者ID:dbre2,项目名称:dynamic-image,代码行数:26,代码来源:PolygonShapeLayer.cs

示例4: ApplyFilter

 protected override void ApplyFilter(FastBitmap source, DrawingContext dc, int width, int height)
 {
     Vector offsetSize = GetOffsetSize() + new Vector(Size, Size);
     dc.PushTransform(new TranslateTransform(offsetSize.X, offsetSize.Y));
     base.ApplyFilter(source, dc, width, height);
     dc.Pop();
 }
开发者ID:pacificIT,项目名称:dynamic-image,代码行数:7,代码来源:DropShadowFilter.cs

示例5: GetEffect

        protected override Effect GetEffect(FastBitmap source)
        {
            // Fill temporary graphics buffer with mask (currently always a rectangle).
            DrawingVisual dv = new DrawingVisual
            {
                Effect = new BlurEffect
                {
                    Radius = Radius,
                    KernelType = KernelType.Gaussian
                }
            };

            DrawingContext dc = dv.RenderOpen();
            dc.DrawImage(source.InnerBitmap, new Rect(0, 0, source.Width, source.Height));
            dc.Close();

            RenderTargetBitmap rtb = RenderTargetBitmapUtility.CreateRenderTargetBitmap(source.Width, source.Height);
            rtb.Render(dv);

            Brush blurredImage = new ImageBrush(rtb);

            return new UnsharpMaskEffect
            {
                BlurMask = blurredImage,
                Amount = Amount / 100.0,
                Threshold = Threshold
            };
        }
开发者ID:sitdap,项目名称:dynamic-image,代码行数:28,代码来源:UnsharpMaskFilter.cs

示例6: GetDestinationDimensions

 /// <summary>
 /// Returns the dimensions of the output image.
 /// </summary>
 /// <param name="source">The source image.</param>
 /// <param name="width">The desired width of the output image.</param>
 /// <param name="height">The desired height of the output image.</param>
 /// <returns><c>true</c> if the destination image should be created; otherwise <c>false</c>.
 /// The <see cref="DropShadowFilter" /> always returns <c>true</c>.</returns>
 protected override bool GetDestinationDimensions(FastBitmap source, out int width, out int height)
 {
     Vector padding = GetPadding();
     width = source.Width + (int) Math.Ceiling(Math.Abs(padding.X));
     height = source.Height + (int) Math.Ceiling(Math.Abs(padding.Y));
     return true;
 }
开发者ID:pacificIT,项目名称:dynamic-image,代码行数:15,代码来源:ShadowFilterBase.cs

示例7: ApplyFilter

        public override void ApplyFilter(ImageGenerationContext context, FastBitmap bitmap)
        {
            if (Width == Unit.Empty && Height == Unit.Empty)
                throw new DynamicImageException("At least one of Width or Height must be set.");

            string sourceFileName = Path.GetTempFileName();
            try
            {
                bitmap.Save(sourceFileName);

                string outputFileName = Path.GetTempFileName();

                try
                {
                    int width = (Width == Unit.Empty) ? bitmap.Width : Unit.GetCalculatedValue(Width, bitmap.Width);
                    int height = (Height == Unit.Empty) ? bitmap.Height : Unit.GetCalculatedValue(Height, bitmap.Height);
                    new CairWrapper(context).ProcessImage(sourceFileName, outputFileName, int.MaxValue,
                        width, height, ConvolutionType);
                    FastBitmap output = new FastBitmap(File.ReadAllBytes(outputFileName));
                    if (output.InnerBitmap != null)
                        bitmap.InnerBitmap = output.InnerBitmap;
                }
                finally
                {
                    File.Delete(outputFileName);
                }
            }
            finally
            {
                File.Delete(sourceFileName);
            }
        }
开发者ID:pacificIT,项目名称:dynamic-image,代码行数:32,代码来源:ContentAwareResizeFilter.cs

示例8: GetEffect

 protected override Effect GetEffect(FastBitmap source)
 {
     return new BrightnessAdjustmentEffect
     {
         Level = this.Level/100.0
     };
 }
开发者ID:sitdap,项目名称:dynamic-image,代码行数:7,代码来源:BrightnessAdjustmentFilter.cs

示例9: GetEffect

        protected override Effect GetEffect(FastBitmap source)
        {
            // Get curves either from Curves collection or ACV file.
            CurveCollection curves = GetCurves();

            // Check that there are at least 4 curves.
            if (curves.Count < 4)
                throw new DynamicImageException(
                    "At least 4 curves (corresponding to Composite, Red, Green, Blue) must be specified.");

            // Convert mathematical curve definitions into 4x256 lookup texture (Composite, Red, Green, Blue are the 4 "columns").
            FastBitmap curvesLookup = new FastBitmap(4, 256);
            curvesLookup.Lock();
            for (int x = 0; x < 4; ++x)
            {
                IEnumerable<CurvePoint> points = curves[x].Points.Cast<CurvePoint>();
                float[] xValues = points.Select(p => (float) p.Input).ToArray();
                float[] yValues = points.Select(p => (float) p.Output).ToArray();
                float[] derivatives = CubicSplineUtility.CalculateSpline(xValues, yValues);
                for (int y = 0; y < 256; ++y)
                    curvesLookup[x, y] = Color.FromRgb((byte) CubicSplineUtility.InterpolateSpline(xValues, yValues, derivatives, y), 0, 0);
            }
            curvesLookup.Unlock();

            return new CurvesEffect
            {
                CurvesLookup = new ImageBrush(curvesLookup.InnerBitmap)
            };
        }
开发者ID:dbre2,项目名称:dynamic-image,代码行数:29,代码来源:CurvesAdjustmentFilter.cs

示例10: ApplyFilter

        /// <summary>
        /// Applies the <see cref="ShinyFloorFilter" /> to the specified <paramref name="source"/>.
        /// </summary>
        /// <param name="source">The source image.</param>
        /// <param name="dc"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        protected override void ApplyFilter(FastBitmap source, DrawingContext dc, int width, int height)
        {
            // First, draw reflected image with an opacity mask.
            int reflectionHeight = (int)(source.Height * (ReflectionPercentage / 100.0f));
            dc.PushTransform(new TransformGroup
            {
                Children = new TransformCollection
                {
                    new ScaleTransform {ScaleY = -1},
                    new TranslateTransform {Y = GetReflectionOffsetY(source) + reflectionHeight}
                }
            });
            dc.PushOpacityMask(new LinearGradientBrush(
                SWMColors.Transparent,
                SWMColor.FromArgb((byte)(255.0f * (ReflectionOpacity / 100.0f)), 0, 0, 0),
                new Point(0, 0),
                new Point(0, 1)));

            dc.DrawImage(new CroppedBitmap(source.InnerBitmap, new Int32Rect(0, source.Height - reflectionHeight, source.Width, reflectionHeight)),
                new Rect(0, 0, source.Width, reflectionHeight));

            dc.Pop();
            dc.Pop();

            // Draw original image.
            dc.DrawImage(source.InnerBitmap, new Rect(0, 0, source.Width, source.Height));
        }
开发者ID:pacificIT,项目名称:dynamic-image,代码行数:34,代码来源:ShinyFloorFilter.cs

示例11: CreateImage

        protected override sealed void CreateImage(ImageGenerationContext context)
        {
            base.CreateImage(context);

            Rect bounds = new Rect(StrokeWidth / 2, StrokeWidth / 2,
                CalculatedWidth - StrokeWidth,
                CalculatedHeight - StrokeWidth);
            Brush brush = Fill.GetBrush();

            Pen pen = GetPen();

            DrawingVisual dv = new DrawingVisual();
            DrawingContext dc = dv.RenderOpen();

            if (Roundness == 0)
                dc.DrawRectangle(brush, pen, bounds);
            else
                dc.DrawRoundedRectangle(brush, pen, bounds, Roundness, Roundness);

            dc.Close();

            RenderTargetBitmap rtb = RenderTargetBitmapUtility.CreateRenderTargetBitmap(CalculatedWidth, CalculatedHeight);
            rtb.Render(dv);
            Bitmap = new FastBitmap(rtb);
        }
开发者ID:pacificIT,项目名称:dynamic-image,代码行数:25,代码来源:RectangleShapeLayer.cs

示例12: GetEffect

 protected override Effect GetEffect(ImageGenerationContext context, FastBitmap source)
 {
     return new ColorTintEffect
     {
         Amount = Amount/100.0,
         RequiredColor = Color.ToWpfColor()
     };
 }
开发者ID:pacificIT,项目名称:dynamic-image,代码行数:8,代码来源:ColorTintFilter.cs

示例13: GetEffect

 protected override Effect GetEffect(FastBitmap source)
 {
     return new EmbossEffect
     {
         Amount = Amount,
         Width = Width/(double) source.Width
     };
 }
开发者ID:sitdap,项目名称:dynamic-image,代码行数:8,代码来源:EmbossFilter.cs

示例14: GetEffect

 protected override Effect GetEffect(ImageGenerationContext context, FastBitmap source)
 {
     return new BlurEffect
     {
         KernelType = KernelType.Gaussian,
         Radius = Radius,
         RenderingBias = RenderingBias.Quality
     };
 }
开发者ID:pacificIT,项目名称:dynamic-image,代码行数:9,代码来源:GaussianBlurFilter.cs

示例15: GetEffect

 protected override Effect GetEffect(FastBitmap source)
 {
     return new BlurEffect
     {
         KernelType = KernelType.Gaussian,
         Radius = Radius,
         RenderingBias = RenderingBias.Quality
     };
 }
开发者ID:dbre2,项目名称:dynamic-image,代码行数:9,代码来源:GaussianBlurFilter.cs


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