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


C# Cairo.Context.SetSourceRGB方法代码示例

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


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

示例1: ClearSurface

		void ClearSurface ()
		{
			using (Cairo.Context ctx = new Cairo.Context (surface)) {
				ctx.SetSourceRGB (1, 1, 1);
				ctx.Paint ();
			}
		}
开发者ID:liberostelios,项目名称:gtk-sharp,代码行数:7,代码来源:Scribble.cs

示例2: HandlePintaCoreActionsFileNewActivated

        private void HandlePintaCoreActionsFileNewActivated(object sender, EventArgs e)
        {
            NewImageDialog dialog = new NewImageDialog ();

            dialog.ParentWindow = main_window.GdkWindow;
            dialog.WindowPosition = Gtk.WindowPosition.CenterOnParent;

            int response = dialog.Run ();

            if (response == (int)Gtk.ResponseType.Ok) {
                PintaCore.Workspace.ImageSize = new Cairo.PointD (dialog.NewImageWidth, dialog.NewImageHeight);
                PintaCore.Workspace.CanvasSize = new Cairo.PointD (dialog.NewImageWidth, dialog.NewImageHeight);

                PintaCore.Layers.Clear ();
                PintaCore.History.Clear ();
                PintaCore.Layers.DestroySelectionLayer ();
                PintaCore.Layers.ResetSelectionPath ();

                // Start with an empty white layer
                Layer background = PintaCore.Layers.AddNewLayer ("Background");

                using (Cairo.Context g = new Cairo.Context (background.Surface)) {
                    g.SetSourceRGB (255, 255, 255);
                    g.Paint ();
                }

                PintaCore.Workspace.Filename = "Untitled1";
                PintaCore.Workspace.IsDirty = false;
                PintaCore.Actions.View.ZoomToWindow.Activate ();
            }

            dialog.Destroy ();
        }
开发者ID:asbjornu,项目名称:Pinta,代码行数:33,代码来源:DialogHandlers.cs

示例3: NewFile

        public void NewFile(Size imageSize)
        {
            PintaCore.Workspace.ActiveDocument.HasFile = false;
            PintaCore.Workspace.ImageSize = imageSize;
            PintaCore.Workspace.CanvasSize = imageSize;

            PintaCore.Layers.Clear ();
            PintaCore.History.Clear ();
            PintaCore.Layers.DestroySelectionLayer ();
            PintaCore.Layers.ResetSelectionPath ();

            // Start with an empty white layer
            Layer background = PintaCore.Layers.AddNewLayer (Catalog.GetString ("Background"));

            using (Cairo.Context g = new Cairo.Context (background.Surface)) {
                g.SetSourceRGB (255, 255, 255);
                g.Paint ();
            }

            PintaCore.Workspace.Filename = "Untitled1";
            PintaCore.History.PushNewItem (new BaseHistoryItem (Stock.New, Catalog.GetString ("New Image")));
            PintaCore.Workspace.IsDirty = false;
            PintaCore.Actions.View.ZoomToWindow.Activate ();
        }
开发者ID:joehillen,项目名称:Pinta,代码行数:24,代码来源:FileActions.cs

示例4: MainWindow

        public MainWindow()
            : base(Gtk.WindowType.Toplevel)
        {
            Build ();

            Requisition req = new Requisition ();
            req.Height = 600;
            req.Width = 800;
            drawingarea1.Requisition = req;

            // Initialize interface things
            PintaCore.Actions.AccelGroup = new AccelGroup ();
            this.AddAccelGroup (PintaCore.Actions.AccelGroup);

            PintaCore.Initialize (tooltoolbar, label5, drawingarea1, treeview1, this);
            colorpalettewidget1.Initialize ();

            PintaCore.Chrome.StatusBarTextChanged += new EventHandler<TextChangedEventArgs> (Chrome_StatusBarTextChanged);
            PintaCore.History.HistoryItemAdded += new EventHandler<HistoryItemAddedEventArgs> (History_HistoryItemAdded);
            PintaCore.History.HistoryItemRemoved += new EventHandler<HistoryItemRemovedEventArgs> (History_HistoryItemRemoved);
            PintaCore.Workspace.CanvasInvalidated += new EventHandler<CanvasInvalidatedEventArgs> (Workspace_CanvasInvalidated);
            PintaCore.Workspace.CanvasSizeChanged += new EventHandler (Workspace_CanvasSizeChanged);
            CreateToolBox ();

            PintaCore.Actions.CreateMainMenu (menubar1);
            PintaCore.Actions.CreateToolBar (toolbar1);
            PintaCore.Actions.Layers.CreateLayerWindowToolBar (toolbar4);
            PintaCore.Actions.Edit.CreateHistoryWindowToolBar (toolbar2);

            Gtk.Image i = new Gtk.Image (PintaCore.Resources.GetIcon ("StatusBar.CursorXY.png"));
            i.Show ();

            statusbar1.Add (i);
            Gtk.Box.BoxChild box = (Gtk.Box.BoxChild)statusbar1[i];
            box.Position = 2;
            box.Fill = false;
            box.Expand = false;

            this.Icon = PintaCore.Resources.GetIcon ("Pinta.png");

            dialog_handler = new DialogHandlers (this);

            // Create a blank document
            Layer background = PintaCore.Layers.AddNewLayer ("Background");

            using (Cairo.Context g = new Cairo.Context (background.Surface)) {
                g.SetSourceRGB (255, 255, 255);
                g.Paint ();
            }

            PintaCore.Workspace.Filename = "Untitled1";
            PintaCore.Workspace.IsDirty = false;

            PintaCore.Workspace.Invalidate ();

            treeview1.Model = new ListStore (typeof (Pixbuf), typeof (string));
            treeview1.HeadersVisible = false;
            treeview1.RowActivated += HandleTreeview1RowActivated;
            AddColumns (treeview1);

            PintaCore.Actions.View.ZoomToWindow.Activated += new EventHandler (ZoomToWindow_Activated);
            DeleteEvent += new DeleteEventHandler (MainWindow_DeleteEvent);

            EffectsAction.Visible = false;
            WindowAction.Visible = false;
        }
开发者ID:asbjornu,项目名称:Pinta,代码行数:66,代码来源:MainWindow.cs

示例5: RedrawText

        /// <summary>
        /// Draws the text.
        /// </summary>
        /// <param name="showCursor">Whether or not to show the mouse cursor in the drawing.</param>
        /// <param name="useTextLayer">Whether or not to use the TextLayer (as opposed to the Userlayer).</param>
        private void RedrawText(bool showCursor, bool useTextLayer)
        {
            Rectangle r = CurrentTextEngine.GetLayoutBounds();
            r.Inflate(10 + OutlineWidth, 10 + OutlineWidth);
            CurrentTextBounds = r;

            Rectangle cursorBounds = Rectangle.Zero;

            Cairo.ImageSurface surf;

            if (!useTextLayer)
            {
                //Draw text on the current UserLayer's surface as finalized text.
                surf = PintaCore.Workspace.ActiveDocument.CurrentUserLayer.Surface;
            }
            else
            {
                //Draw text on the current UserLayer's TextLayer's surface as re-editable text.
                surf = PintaCore.Workspace.ActiveDocument.CurrentUserLayer.TextLayer.Surface;

                ClearTextLayer();
            }

            using (var g = new Cairo.Context (surf)) {
                g.Save ();

                // Show selection if on text layer
                if (useTextLayer) {
                    // Selected Text
                    Cairo.Color c = new Cairo.Color (0.7, 0.8, 0.9, 0.5);
                    foreach (Rectangle rect in CurrentTextEngine.SelectionRectangles)
                        g.FillRectangle (rect.ToCairoRectangle (), c);
                }
                g.AppendPath (PintaCore.Workspace.ActiveDocument.Selection.SelectionPath);
                g.FillRule = Cairo.FillRule.EvenOdd;
                g.Clip ();

                g.MoveTo (new Cairo.PointD (CurrentTextEngine.Origin.X, CurrentTextEngine.Origin.Y));

                g.SetSourceRGBA (PintaCore.Palette.PrimaryColor);

                //Fill in background
                if (BackgroundFill) {
                    using (var g2 = new Cairo.Context (surf)) {
                        g2.FillRectangle(CurrentTextEngine.GetLayoutBounds().ToCairoRectangle(), PintaCore.Palette.SecondaryColor);
                    }
                }

                // Draw the text
                if (FillText)
                    Pango.CairoHelper.ShowLayout (g, CurrentTextEngine.Layout);

                if (FillText && StrokeText) {
                    g.SetSourceRGBA (PintaCore.Palette.SecondaryColor);
                    g.LineWidth = OutlineWidth;

                    Pango.CairoHelper.LayoutPath (g, CurrentTextEngine.Layout);
                    g.Stroke ();
                } else if (StrokeText) {
                    g.SetSourceRGBA (PintaCore.Palette.PrimaryColor);
                    g.LineWidth = OutlineWidth;

                    Pango.CairoHelper.LayoutPath (g, CurrentTextEngine.Layout);
                    g.Stroke ();
                }

                if (showCursor) {
                    var loc = CurrentTextEngine.GetCursorLocation ();

                    g.Antialias = Cairo.Antialias.None;
                    g.DrawLine (new Cairo.PointD (loc.X, loc.Y), new Cairo.PointD (loc.X, loc.Y + loc.Height), new Cairo.Color (0, 0, 0, 1), 1);

                    cursorBounds = Rectangle.Inflate (loc, 2, 10);
                }

                g.Restore ();

                if (useTextLayer && (is_editing || ctrlKey) && !CurrentTextEngine.IsEmpty())
                {
                    //Draw the text edit rectangle.

                    g.Save();

                    g.Translate(.5, .5);

                    using (Cairo.Path p = g.CreateRectanglePath(new Cairo.Rectangle(CurrentTextBounds.Left, CurrentTextBounds.Top,
                        CurrentTextBounds.Width, CurrentTextBounds.Height - FontSize)))
                    {
                        g.AppendPath(p);
                    }

                    g.LineWidth = 1;

                    g.SetSourceRGB (1, 1, 1);
                    g.StrokePreserve();
//.........这里部分代码省略.........
开发者ID:CiprianKhlud,项目名称:Pinta,代码行数:101,代码来源:TextTool.cs

示例6: NewFile

        public void NewFile(Size imageSize)
        {
            PintaCore.Workspace.CreateAndActivateDocument (null, imageSize);
            PintaCore.Workspace.ActiveDocument.HasFile = false;
            PintaCore.Workspace.ActiveWorkspace.CanvasSize = imageSize;

            // Start with an empty white layer
            Layer background = PintaCore.Workspace.ActiveDocument.AddNewLayer (Catalog.GetString ("Background"));

            using (Cairo.Context g = new Cairo.Context (background.Surface)) {
                g.SetSourceRGB (1, 1, 1);
                g.Paint ();
            }

            PintaCore.Workspace.ActiveWorkspace.History.PushNewItem (new BaseHistoryItem (Stock.New, Catalog.GetString ("New Image")));
            PintaCore.Workspace.ActiveDocument.IsDirty = false;
            PintaCore.Actions.View.ZoomToWindow.Activate ();
        }
开发者ID:linuxmhall,项目名称:Pinta,代码行数:18,代码来源:FileActions.cs

示例7: MainWindow

        public MainWindow()
            : base(Gtk.WindowType.Toplevel)
        {
            Build ();

            Requisition req = new Requisition ();
            req.Height = 600;
            req.Width = 800;
            drawingarea1.Requisition = req;

            // Initialize interface things
            PintaCore.Actions.AccelGroup = new AccelGroup ();
            this.AddAccelGroup (PintaCore.Actions.AccelGroup);

            PintaCore.Initialize (tooltoolbar, label5, drawingarea1, treeview1, this);
            colorpalettewidget1.Initialize ();

            PintaCore.Chrome.StatusBarTextChanged += new EventHandler<TextChangedEventArgs> (Chrome_StatusBarTextChanged);
            PintaCore.History.HistoryItemAdded += new EventHandler<HistoryItemAddedEventArgs> (History_HistoryItemAdded);
            PintaCore.History.HistoryItemRemoved += new EventHandler<HistoryItemRemovedEventArgs> (History_HistoryItemRemoved);
            PintaCore.Workspace.CanvasInvalidated += new EventHandler<CanvasInvalidatedEventArgs> (Workspace_CanvasInvalidated);
            PintaCore.Workspace.CanvasSizeChanged += new EventHandler (Workspace_CanvasSizeChanged);
            CreateToolBox ();

            PintaCore.Actions.CreateMainMenu (menubar1);
            PintaCore.Actions.CreateToolBar (toolbar1);
            PintaCore.Actions.Layers.CreateLayerWindowToolBar (toolbar4);
            PintaCore.Actions.Edit.CreateHistoryWindowToolBar (toolbar2);

            Gtk.Image i = new Gtk.Image (PintaCore.Resources.GetIcon ("StatusBar.CursorXY.png"));
            i.Show ();

            statusbar1.Add (i);
            Gtk.Box.BoxChild box = (Gtk.Box.BoxChild)statusbar1[i];
            box.Position = 2;
            box.Fill = false;
            box.Expand = false;

            this.Icon = PintaCore.Resources.GetIcon ("Pinta.png");

            dialog_handler = new DialogHandlers (this);

            // Create a blank document
            Layer background = PintaCore.Layers.AddNewLayer ("Background");

            using (Cairo.Context g = new Cairo.Context (background.Surface)) {
                g.SetSourceRGB (255, 255, 255);
                g.Paint ();
            }

            PintaCore.Workspace.Filename = "Untitled1";
            PintaCore.Workspace.IsDirty = false;

            PintaCore.Workspace.Invalidate ();

            treeview1.Model = new ListStore (typeof (Pixbuf), typeof (string));
            treeview1.HeadersVisible = false;
            treeview1.RowActivated += HandleTreeview1RowActivated;
            AddColumns (treeview1);

            PintaCore.Actions.View.ZoomToWindow.Activated += new EventHandler (ZoomToWindow_Activated);
            DeleteEvent += new DeleteEventHandler (MainWindow_DeleteEvent);

            WindowAction.Visible = false;

            if (Platform.GetOS () == Platform.OS.Mac)
            {
                try {
                    //enable the global key handler for keyboard shortcuts
                    IgeMacMenu.GlobalKeyHandlerEnabled = true;

                    //Tell the IGE library to use your GTK menu as the Mac main menu
                    IgeMacMenu.MenuBar = menubar1;
                    /*
                    //tell IGE which menu item should be used for the app menu's quit item
                    IgeMacMenu.QuitMenuItem = yourQuitMenuItem;
                    */
                    //add a new group to the app menu, and add some items to it
                    var appGroup = IgeMacMenu.AddAppMenuGroup();
                    MenuItem aboutItem = (MenuItem) PintaCore.Actions.Help.About.CreateMenuItem();
                    appGroup.AddMenuItem(aboutItem, Mono.Unix.Catalog.GetString ("About"));

                    menubar1.Hide();
                } catch {
                    // If things don't work out, just use a normal menu.
                }
            }
        }
开发者ID:deckarep,项目名称:Pinta,代码行数:88,代码来源:MainWindow.cs

示例8: MainWindow

        public MainWindow()
            : base(Gtk.WindowType.Toplevel)
        {
            Build ();

            Requisition req = new Requisition ();
            req.Height = 600;
            req.Width = 800;
            drawingarea1.Requisition = req;

            // Initialize interface things
            PintaCore.Actions.AccelGroup = new AccelGroup ();
            this.AddAccelGroup (PintaCore.Actions.AccelGroup);

            progress_dialog = new ProgressDialog ();

            PintaCore.Initialize (tooltoolbar, label5, drawingarea1, history_treeview, this, progress_dialog, (Gtk.Viewport)table1.Parent);
            colorpalettewidget1.Initialize ();

            PintaCore.Chrome.StatusBarTextChanged += new EventHandler<TextChangedEventArgs> (Chrome_StatusBarTextChanged);
            PintaCore.Workspace.CanvasInvalidated += new EventHandler<CanvasInvalidatedEventArgs> (Workspace_CanvasInvalidated);
            PintaCore.Workspace.CanvasSizeChanged += new EventHandler (Workspace_CanvasSizeChanged);
            CreateToolBox ();

            PintaCore.Actions.CreateMainMenu (menubar1);
            PintaCore.Actions.CreateToolBar (toolbar1);
            PintaCore.Actions.Layers.CreateLayerWindowToolBar (toolbar4);
            PintaCore.Actions.Edit.CreateHistoryWindowToolBar (toolbar2);

            Gtk.Image i = new Gtk.Image (PintaCore.Resources.GetIcon ("StatusBar.CursorXY.png"));
            i.Show ();

            statusbar1.Add (i);
            Gtk.Box.BoxChild box = (Gtk.Box.BoxChild)statusbar1[i];
            box.Position = 2;
            box.Fill = false;
            box.Expand = false;

            this.Icon = PintaCore.Resources.GetIcon ("Pinta.png");

            dialog_handler = new DialogHandlers (this);

            // Create a blank document
            Layer background = PintaCore.Layers.AddNewLayer ("Background");

            using (Cairo.Context g = new Cairo.Context (background.Surface)) {
                g.SetSourceRGB (255, 255, 255);
                g.Paint ();
            }

            PintaCore.Workspace.Filename = "Untitled1";
            PintaCore.History.PushNewItem (new BaseHistoryItem ("gtk-new", "New Image"));
            PintaCore.Workspace.IsDirty = false;
            PintaCore.Workspace.Invalidate ();

            //History
            history_treeview.Model = PintaCore.History.ListStore;
            history_treeview.HeadersVisible = false;
            history_treeview.Selection.Mode = SelectionMode.Single;
            history_treeview.Selection.SelectFunction = HistoryItemSelected;

            Gtk.TreeViewColumn icon_column = new Gtk.TreeViewColumn ();
            Gtk.CellRendererPixbuf icon_cell = new Gtk.CellRendererPixbuf ();
            icon_column.PackStart (icon_cell, true);

            Gtk.TreeViewColumn text_column = new Gtk.TreeViewColumn ();
            Gtk.CellRendererText text_cell = new Gtk.CellRendererText ();
            text_column.PackStart (text_cell, true);

            text_column.SetCellDataFunc (text_cell, new Gtk.TreeCellDataFunc (HistoryRenderText));
            icon_column.SetCellDataFunc (icon_cell, new Gtk.TreeCellDataFunc (HistoryRenderIcon));

            history_treeview.AppendColumn (icon_column);
            history_treeview.AppendColumn (text_column);

            PintaCore.History.HistoryItemAdded += new EventHandler<HistoryItemAddedEventArgs> (OnHistoryItemsChanged);
            PintaCore.History.ActionUndone += new EventHandler (OnHistoryItemsChanged);
            PintaCore.History.ActionRedone += new EventHandler (OnHistoryItemsChanged);

            PintaCore.Actions.View.ZoomToWindow.Activated += new EventHandler (ZoomToWindow_Activated);
            DeleteEvent += new DeleteEventHandler (MainWindow_DeleteEvent);

            PintaCore.LivePreview.RenderUpdated += LivePreview_RenderUpdated;

            WindowAction.Visible = false;

            hruler = new HRuler ();
            hruler.Metric = MetricType.Pixels;
            table1.Attach (hruler, 1, 2, 0, 1, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0);

            vruler = new VRuler ();
            vruler.Metric = MetricType.Pixels;
            table1.Attach (vruler, 0, 1, 1, 2, AttachOptions.Shrink | AttachOptions.Fill, AttachOptions.Shrink | AttachOptions.Fill, 0, 0);

            UpdateRulerRange ();

            PintaCore.Actions.View.ZoomComboBox.ComboBox.Changed += HandlePintaCoreActionsViewZoomComboBoxComboBoxChanged;

            gr = new GridRenderer (cr);

//.........这里部分代码省略.........
开发者ID:mrolappe,项目名称:Pinta,代码行数:101,代码来源:MainWindow.cs

示例9: ScribbleConfigure

        // Create a new surface of the appropriate size to store our scribbles
        private void ScribbleConfigure(object o, ConfigureEventArgs args)
        {
            Widget widget = o as Widget;

            if (surface != null)
                surface.Destroy ();

            var allocation = widget.Allocation;

            surface = widget.Window.CreateSimilarSurface (Cairo.Content.Color, allocation.Width, allocation.Height);
            var cr = new Cairo.Context (surface);

            cr.SetSourceRGB (1, 1, 1);
            cr.Paint ();
            ((IDisposable)cr).Dispose ();

            // We've handled the configure event, no need for further processing.
            args.RetVal = true;
        }
开发者ID:Gravecorp,项目名称:gtk-sharp,代码行数:20,代码来源:DemoDrawingArea.cs

示例10: DrawConstDataIcon

        protected Gdk.Pixbuf DrawConstDataIcon()
        {
            using (var surface = new Cairo.ImageSurface (Cairo.Format.Argb32, rectSizing.Width, rectSizing.Height)) {
                using (Cairo.Context cr = new Cairo.Context (surface)) {
                    // background
                    cr.SetSourceRGB (0.7, 0.7, 0.7);
                    cr.Paint ();

                    // text
                    cr.SetSourceRGB (1, 0, 0);
                    // simple Cairo text API instead of Pango
                    //cr.MoveTo (10, 0.3 * height);
                    //cr.SetFontSize (20);
                    //cr.ShowText ("const");

                    using (var layout = Pango.CairoHelper.CreateLayout (cr)) {
                        // font size 12 seems suitable for iconHeight 48 pixels
                        float fontSize = 12 * rectSizing.Height / 48f;
                        layout.FontDescription = Pango.FontDescription.FromString ("Sans " + fontSize.ToString ());
                        layout.SetText ("const");
                        layout.Width = rectSizing.Width;
                        layout.Alignment = Pango.Alignment.Center;
                        int lwidth, lheight;
                        layout.GetPixelSize (out lwidth, out lheight);
                        // 0, 0 = left top
                        //cr.MoveTo (0.5 * (width - lwidth), 0.5 * (height - lheight));
                        cr.MoveTo (0.5 * rectSizing.Width, 0.5 * (rectSizing.Height - lheight));
                        Pango.CairoHelper.ShowLayout (cr, layout);
                    }
                }
                return new Gdk.Pixbuf (surface.Data, Gdk.Colorspace.Rgb, true, 8, rectSizing.Width, rectSizing.Height, surface.Stride, null);
            }
        }
开发者ID:SubaruDieselCrew,项目名称:ScoobyRom,代码行数:33,代码来源:PlotIconBase.cs

示例11: CreateBitmap

        internal static Gdk.Pixbuf CreateBitmap(string stockId, double width, double height, double scaleFactor)
        {
            Gdk.Pixbuf result = null;

            Gtk.IconSet iconset = Gtk.IconFactory.LookupDefault (stockId);
            if (iconset != null) {
                // Find the size that better fits the requested size
                Gtk.IconSize gsize = Util.GetBestSizeFit (width);
                result = iconset.RenderIcon (Gtk.Widget.DefaultStyle, Gtk.TextDirection.Ltr, Gtk.StateType.Normal, gsize, null, null, scaleFactor);
                if (result == null || result.Width < width * scaleFactor) {
                    var gsize2x = Util.GetBestSizeFit (width * scaleFactor, iconset.Sizes);
                    if (gsize2x != Gtk.IconSize.Invalid && gsize2x != gsize)
                        // Don't dispose the previous result since the icon is owned by the IconSet
                        result = iconset.RenderIcon (Gtk.Widget.DefaultStyle, Gtk.TextDirection.Ltr, Gtk.StateType.Normal, gsize2x, null, null);
                }
            }

            if (result == null && Gtk.IconTheme.Default.HasIcon (stockId))
                result = Gtk.IconTheme.Default.LoadIcon (stockId, (int)width, (Gtk.IconLookupFlags)0);

            if (result == null)
            {
                // render a custom gtk-missing-image icon
                // if Gtk.Stock.MissingImage is not found
                int w = (int)width;
                int h = (int)height;
                #if XWT_GTK3
                Cairo.ImageSurface s = new Cairo.ImageSurface(Cairo.Format.ARGB32, w, h);
                Cairo.Context cr = new Cairo.Context(s);
                cr.SetSourceRGB(255, 255, 255);
                cr.Rectangle(0, 0, w, h);
                cr.Fill();
                cr.SetSourceRGB(0, 0, 0);
                cr.LineWidth = 1;
                cr.Rectangle(0.5, 0.5, w - 1, h - 1);
                cr.Stroke();
                cr.SetSourceRGB(255, 0, 0);
                cr.LineWidth = 3;
                cr.LineCap = Cairo.LineCap.Round;
                cr.LineJoin = Cairo.LineJoin.Round;
                cr.MoveTo(w / 4, h / 4);
                cr.LineTo((w - 1) - w / 4, (h - 1) - h / 4);
                cr.MoveTo(w / 4, (h - 1) - h / 4);
                cr.LineTo((w - 1) - w / 4, h / 4);
                cr.Stroke();
                result = Gtk3Extensions.GetFromSurface(s, 0, 0, w, h);
                #else
                using (Gdk.Pixmap pmap = new Gdk.Pixmap (Gdk.Screen.Default.RootWindow, w, h))
                using (Gdk.GC gc = new Gdk.GC (pmap)) {
                    gc.RgbFgColor = new Gdk.Color (255, 255, 255);
                    pmap.DrawRectangle (gc, true, 0, 0, w, h);
                    gc.RgbFgColor = new Gdk.Color (0, 0, 0);
                    pmap.DrawRectangle (gc, false, 0, 0, (w - 1), (h - 1));
                    gc.SetLineAttributes (3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
                    gc.RgbFgColor = new Gdk.Color (255, 0, 0);
                    pmap.DrawLine (gc, (w / 4), (h / 4), ((w - 1) - (w / 4)), ((h - 1) - (h / 4)));
                    pmap.DrawLine (gc, ((w - 1) - (w / 4)), (h / 4), (w / 4), ((h - 1) - (h / 4)));
                    result = Gdk.Pixbuf.FromDrawable (pmap, pmap.Colormap, 0, 0, 0, 0, w, h);
                }
                #endif
            }
            return result;
        }
开发者ID:mono,项目名称:xwt,代码行数:63,代码来源:ImageHandler.cs


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