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


C# Pixbuf.AddAlpha方法代码示例

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


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

示例1: RenderBubbles

   private void RenderBubbles(Gdk.Window win, Gdk.Rectangle size,
 out Pixbuf pbactive, out Pixbuf pbinactive,
 out Gdk.Pixmap pbpm)
   {
       int pmHeight, pmWidth;
          Gdk.Pixmap daPixmap;
          Gdk.Pixmap daOtherPixmap;
          pmHeight = size.Height - (wbsize * 2);
          pmWidth = size.Width - (wbsize * 2);
          Gdk.GC gc = new Gdk.GC(win);
          Gdk.Pixmap pm = new Pixmap(win, size.Width, size.Height, -1);
          gc.RgbFgColor = new Gdk.Color(255, 255, 255);
          pm.DrawRectangle(gc, true, 0, 0, size.Width, size.Height);
          gc.RgbFgColor = new Gdk.Color(249, 253, 202);
          Gdk.Point[] roundedSquare = CalculateRect(wbsize, wbsize,
         pmWidth, pmHeight);
          pm.DrawPolygon(gc, true, roundedSquare);
          Gdk.Point[] roundedborder = CalculateRect(wbsize, wbsize,
       pmWidth - 1, pmHeight - 1);
          gc.RgbFgColor = new Gdk.Color(0, 0, 0);
          pm.DrawPolygon(gc, false, roundedborder);
          Gdk.Point[] balloonptr = CalcPointerMoveWindow( size.Width,
        size.Height );
          gc.RgbFgColor = new Gdk.Color(249, 253, 202);
          pm.DrawPolygon(gc, true, balloonptr);
          gc.RgbFgColor = new Gdk.Color(0, 0, 0);
          pm.DrawLine(gc, balloonptr[0].X, balloonptr[0].Y-1, balloonptr[1].X,
          balloonptr[1].Y);
          pm.DrawLine(gc, balloonptr[1].X, balloonptr[1].Y, balloonptr[2].X,
          balloonptr[2].Y-1);
          Gdk.Pixbuf pb = new Pixbuf(Gdk.Colorspace.Rgb, false,
         8, size.Width, size.Height);
          pb = Pixbuf.FromDrawable( pm, pm.Colormap, 0, 0, 0, 0,
         size.Width, size.Height);
          pb = pb.AddAlpha(true, 255, 255,255);
          RenderPixmapAndMask(pb, out daPixmap, out daOtherPixmap, 2);
          pbactive = pb;
          pbpm = daOtherPixmap;
          gc.RgbFgColor = new Gdk.Color(255, 255, 255);
          pm.DrawRectangle(gc, true, 0, 0, size.Width, size.Height);
          gc.RgbFgColor = new Gdk.Color(0, 0, 0);
          pm.DrawPolygon(gc, false, roundedborder);
          gc.RgbFgColor = new Gdk.Color(255, 255, 255);
          pm.DrawPolygon(gc, true, balloonptr);
          gc.RgbFgColor = new Gdk.Color(0, 0, 0);
          pm.DrawLine(gc, balloonptr[0].X, balloonptr[0].Y-1, balloonptr[1].X,
          balloonptr[1].Y);
          pm.DrawLine(gc, balloonptr[1].X, balloonptr[1].Y, balloonptr[2].X,
          balloonptr[2].Y - 1);
          pb = Pixbuf.FromDrawable( pm,
         pm.Colormap, 0, 0, 0, 0, size.Width, size.Height);
          pbinactive = pb;
   }
开发者ID:RoDaniel,项目名称:featurehouse,代码行数:53,代码来源:NotifyWindow.cs

示例2: UnsharpMask

    public static unsafe Pixbuf UnsharpMask(Pixbuf src,
                                             double radius,
                                             double amount,
                                             double threshold,
                                             ThreadProgressDialog progressDialog)
    {
        // Make sure the pixbuf has an alpha channel before we try to blur it
        src = src.AddAlpha (false, 0, 0, 0);

        Pixbuf result = Blur (src, (int)radius, progressDialog);

        int sourceRowstride = src.Rowstride;
        int sourceHeight = src.Height;
        int sourceChannels = src.NChannels;
        int sourceWidth = src.Width;

        int resultRowstride = result.Rowstride;
        int resultWidth = result.Width;
        int resultChannels = result.NChannels;

        byte[] srcRow = new byte[sourceRowstride];
        byte[] destRow = new byte[resultRowstride];

        byte* sourcePixels = (byte*)src.Pixels;
        byte* resultPixels = (byte*)result.Pixels;

        for (int row=0; row < sourceHeight; row++) {
            Pixbuf_GetRow (sourcePixels, row, sourceRowstride, sourceWidth, sourceChannels, srcRow);
            Pixbuf_GetRow (resultPixels, row, resultRowstride, resultWidth, resultChannels, destRow);

            int diff;
            for (int i=0; i < sourceWidth*sourceChannels; i++) {
                diff = srcRow [i] - destRow [i];
                if (Math.Abs (2 * diff) < threshold)
                    diff = 0;

                int val = (int)(srcRow [i] + amount * diff);

                if (val > 255)
                    val = 255;
                else if (val < 0)
                    val = 0;

                destRow [i] = (byte)val;
            }

            Pixbuf_SetRow (resultPixels, destRow, row, resultRowstride, resultWidth, resultChannels);

            // This is the other half of the progress so start and halfway
            if (progressDialog != null)
                progressDialog.Fraction = ((double)row / ((double) sourceHeight - 1) ) * 0.25 + 0.75;
        }

        return result;
    }
开发者ID:GNOME,项目名称:f-spot,代码行数:55,代码来源:PixbufUtils.cs


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