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


C# Context.PaintWithAlpha方法代码示例

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


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

示例1: Draw

        protected override void Draw(Context cr, Pixbuf prev, Pixbuf next, int width, int height, double progress)
        {
            cr.Color = new Color (0, 0, 0, progress);
            if (next != null) {
                double scale = Math.Min ((double)width/(double)next.Width, (double)height/(double)next.Height);
                cr.Save ();

                cr.Rectangle (0, 0, width, .5 * (height - scale*next.Height));
                cr.Fill ();

                cr.Rectangle (0, height - .5 * (height - scale*next.Height), width, .5 * (height - scale*next.Height));
                cr.Fill ();

                cr.Rectangle (0, 0, .5 * (width - scale*next.Width), height);
                cr.Fill ();

                cr.Rectangle (width - .5 * (width - scale*next.Width), 0, .5 * (width - scale*next.Width), height);
                cr.Fill ();

                cr.Rectangle (0, 0, width, height);
                cr.Scale (scale, scale);
                CairoHelper.SetSourcePixbuf (cr, next, .5 * ((double)width/scale - next.Width), .5 * ((double)height/scale - next.Height));
                cr.PaintWithAlpha (progress);
                cr.Restore ();
            }
        }
开发者ID:nathansamson,项目名称:F-Spot-Album-Exporter,代码行数:26,代码来源:DissolveTransition.cs

示例2: Render

        public override void Render(Node node, Context context)
        {
            ImageNode image = node as ImageNode;

            ImageSurface surfaceCache = image.Data as ImageSurface;
            if (surfaceCache == null) {
                surfaceCache = new ImageSurface (image.File);
            }
            int x = (int)((image.Width - surfaceCache.Width) * image.XAlign);
            int y = (int)((image.Height - surfaceCache.Height) * image.YAlign);
            context.SetSourceSurface (surfaceCache, x, y);
            double opacity = image.Opacity;
            if (opacity == 1)
                context.Paint ();
            else
                context.PaintWithAlpha (image.Opacity);
        }
开发者ID:Clancey,项目名称:Canvas,代码行数:17,代码来源:ImageNodeRenderer.cs

示例3: Save

 private void Save(string filename,bool bSource,bool bDrawings)
 {
     Surface pngSurface = new ImageSurface(Format.ARGB32,sourceWidth,sourceHeight);
     using(Context c = new Context(pngSurface)) {
         if(bSource) {
             c.SetSourceSurface(source,0,0);
             c.Paint();
         }
         if(bDrawings) {
             c.SetSourceSurface(drawings,0,0);
             c.PaintWithAlpha(transparency);
         }
     }
     pngSurface.WriteToPng(filename);
 }
开发者ID:dineshkummarc,项目名称:longomatch,代码行数:15,代码来源:DrawingWidget.cs

示例4: DrawWithOperator

        public void DrawWithOperator(Context ctx, ImageSurface surface, Operator op, double opacity = 1.0, bool transform = true)
        {
            ctx.Save ();

            if (transform)
                ctx.Transform (Transform);
            ctx.Operator = op;
            ctx.SetSourceSurface (surface, 0, 0);
            if (opacity >= 1.0)
                ctx.Paint ();
            else
                ctx.PaintWithAlpha (opacity);
            ctx.Restore ();
        }
开发者ID:PintaProject,项目名称:Pinta,代码行数:14,代码来源:Layer.cs

示例5: MergeCurrentLayerDown

        // Flatten current layer
        public void MergeCurrentLayerDown()
        {
            if (current_layer == 0)
                throw new InvalidOperationException ("Cannot flatten layer because current layer is the bottom layer.");

            Layer source = CurrentLayer;
            Layer dest = Layers[current_layer - 1];

            using (Cairo.Context g = new Cairo.Context (dest.Surface)) {
                g.SetSource (source.Surface);
                g.PaintWithAlpha (source.Opacity);
            }

            DeleteCurrentLayer ();
        }
开发者ID:linuxmhall,项目名称:Pinta,代码行数:16,代码来源:Document.cs

示例6: GetFlattenedImage

        public ImageSurface GetFlattenedImage()
        {
            Cairo.ImageSurface surf = new Cairo.ImageSurface (Cairo.Format.Argb32, ImageSize.Width, ImageSize.Height);

            using (Cairo.Context g = new Cairo.Context (surf)) {
                foreach (var layer in GetLayersToPaint ()) {
                    g.SetSource (layer.Surface);
                    g.PaintWithAlpha (layer.Opacity);
                }
            }

            return surf;
        }
开发者ID:linuxmhall,项目名称:Pinta,代码行数:13,代码来源:Document.cs

示例7: FlattenImage

        // Flatten image
        public void FlattenImage()
        {
            if (Layers.Count < 2)
                throw new InvalidOperationException ("Cannot flatten image because there is only one layer.");

            Layer dest = Layers[0];

            using (Cairo.Context g = new Cairo.Context (dest.Surface)) {
                for (int i = 1; i < Layers.Count; i++) {
                    Layer source = Layers[i];
                    g.SetSource (source.Surface);
                    g.PaintWithAlpha (source.Opacity);
                }
            }

            current_layer = 0;

            while (Layers.Count > 1) {
                Layer l = Layers[1];

                Layers.RemoveAt (1);
            }

            PintaCore.Layers.OnLayerRemoved ();
            Workspace.Invalidate ();
        }
开发者ID:linuxmhall,项目名称:Pinta,代码行数:27,代码来源:Document.cs

示例8: FinishSelection

        public void FinishSelection()
        {
            // We don't have an uncommitted layer, abort
            if (!ShowSelectionLayer)
                return;

            FinishPixelsHistoryItem hist = new FinishPixelsHistoryItem ();
            hist.TakeSnapshot ();

            Layer layer = SelectionLayer;

            using (Cairo.Context g = new Cairo.Context (CurrentLayer.Surface)) {
                g.Save ();

                g.SetSourceSurface (layer.Surface, (int)layer.Offset.X, (int)layer.Offset.Y);
                g.PaintWithAlpha (layer.Opacity);

                g.Restore ();
            }

            DestroySelectionLayer ();
            Workspace.Invalidate ();

            Workspace.History.PushNewItem (hist);
        }
开发者ID:linuxmhall,项目名称:Pinta,代码行数:25,代码来源:Document.cs

示例9: GetComputedPixel

		/// <summary>
		/// Gets the final pixel color for the given point, taking layers, opacity, and blend modes into account.
		/// </summary>
		public ColorBgra GetComputedPixel (int x, int y)
		{
            using (var dst = new ImageSurface (Format.Argb32, 1, 1)) {
                using (var g = new Context (dst)) {
			        foreach (var layer in GetLayersToPaint ()) {
                        var color = layer.Surface.GetColorBgraUnchecked (x, y).ToStraightAlpha ().ToCairoColor ();

                        g.SetBlendMode (layer.BlendMode);
                        g.SetSourceColor (color);

                        g.Rectangle (dst.GetBounds ().ToCairoRectangle ());
                        g.PaintWithAlpha (layer.Opacity);
                    }
                }

                return dst.GetColorBgraUnchecked (0, 0);
            }
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:21,代码来源:Document.cs

示例10: Draw

 public void Draw(Context ctx, ImageSurface surface, double opacity)
 {
     ctx.Save();
     ctx.Transform(Transform);
     ctx.SetSourceSurface(surface, 0, 0);
     ctx.PaintWithAlpha(opacity);
     ctx.Restore();
 }
开发者ID:Kharevich,项目名称:Pinta,代码行数:8,代码来源:Layer.cs


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