本文整理汇总了C#中Cairo.Context类的典型用法代码示例。如果您正苦于以下问题:C# Cairo.Context类的具体用法?C# Cairo.Context怎么用?C# Cairo.Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cairo.Context类属于命名空间,在下文中一共展示了Cairo.Context类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DrawInRegionVisitor
public DrawInRegionVisitor(Gdk.Region region, Cairo.Context context, IDrawingView view)
{
this.context = context;
this.region = region;
this.view = view;
this.figures = new List<Figure> ();
}
开发者ID:erbriones,项目名称:monodevelop-classdesigner,代码行数:7,代码来源:DrawInRegionVisitor.cs
示例2: Import
public void Import (string fileName, Gtk.Window parent)
{
Pixbuf bg;
// Handle any EXIF orientation flags
using (var fs = new FileStream (fileName, FileMode.Open, FileAccess.Read))
bg = new Pixbuf (fs);
bg = bg.ApplyEmbeddedOrientation ();
Size imagesize = new Size (bg.Width, bg.Height);
Document doc = PintaCore.Workspace.CreateAndActivateDocument (fileName, imagesize);
doc.HasFile = true;
doc.ImageSize = imagesize;
doc.Workspace.CanvasSize = imagesize;
Layer layer = doc.AddNewLayer (Path.GetFileName (fileName));
using (Cairo.Context g = new Cairo.Context (layer.Surface)) {
CairoHelper.SetSourcePixbuf (g, bg, 0, 0);
g.Paint ();
}
bg.Dispose ();
}
开发者ID:msiyer,项目名称:Pinta,代码行数:26,代码来源:GdkPixbufFormat.cs
示例3: Activated
private void Activated(object sender, EventArgs e)
{
Gtk.Clipboard cb = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
if (cb.WaitIsImageAvailable ()) {
PintaCore.Tools.Commit ();
Gdk.Pixbuf image = cb.WaitForImage ();
Layer l = PintaCore.Layers.AddNewLayer (string.Empty);
using (Cairo.Context g = new Cairo.Context (l.Surface))
g.DrawPixbuf (image, new Cairo.Point (0, 0));
// Make new layer the current layer
PintaCore.Layers.SetCurrentLayer (l);
PintaCore.Workspace.Invalidate ();
AddLayerHistoryItem hist = new AddLayerHistoryItem (Stock.Paste, Catalog.GetString ("Paste Into New Layer"), PintaCore.Layers.IndexOf (l));
PintaCore.History.PushNewItem (hist);
} else {
ClipboardEmptyError ();
}
}
开发者ID:rolandixor,项目名称:Pinta,代码行数:25,代码来源:PasteIntoNewLayerAction.cs
示例4: 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
示例5: 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
示例6: RefreshBackground
public void RefreshBackground(Field[,] fields)
{
background = new Cairo.ImageSurface (Cairo.Format.ARGB32, width * fieldSize, height * fieldSize);
using (Cairo.Context context = new Cairo.Context(background)) {
paintBackground (context, fields);
}
}
开发者ID:Teyras,项目名称:Bounce,代码行数:7,代码来源:BoardRenderer.cs
示例7: GetFileBytes
public byte[] GetFileBytes(Report report)
{
var pages = report.BuildPages();
int width = (int)report.PageWidthPoints;
int height = (int)report.PageHeightPoints;
string filename = string.Format("gen-{0}.pdf", Guid.NewGuid());
try
{
using (Cairo.PdfSurface pdf = new Cairo.PdfSurface(filename, width, height))
{
using (Cairo.Context g = new Cairo.Context(pdf))
{
var render = new fyiReporting.RdlGtkViewer.RenderCairo(g);
render.RunPages(pages);
}
}
byte[] bytes = File.ReadAllBytes(filename);
return bytes;
}
finally
{
if (File.Exists(filename))
{
File.Delete(filename);
}
}
}
开发者ID:myersBR,项目名称:My-FyiReporting,代码行数:30,代码来源:CairoPdfWriter.cs
示例8: OnContextInitialize
public void OnContextInitialize(RenderContextInitEventArgs args)
{
DrawingArea area = args.Widget as DrawingArea;
if (area != null)
{
_context = Gdk.CairoHelper.Create(area.GdkWindow);
}
}
开发者ID:oraora81,项目名称:NOCmono,代码行数:8,代码来源:RenderContext.cs
示例9: FillContains
internal bool FillContains(Point point)
{
using (var context = new Cairo.Context(new Cairo.ImageSurface(Cairo.Format.Argb32, 0, 0)))
{
context.AppendPath(Path);
return context.InFill(point.X, point.Y);
}
}
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:8,代码来源:StreamGeometryContextImpl.cs
示例10: RenderCairo
public RenderCairo(Cairo.Context g, float scale)
{
this.g = g;
this.layout = Pango.CairoHelper.CreateLayout(g);
dpiX *= scale;
dpiY *= scale;
}
开发者ID:myersBR,项目名称:My-FyiReporting,代码行数:8,代码来源:RenderCairo.cs
示例11: DrawBrush
void DrawBrush (double x, double y)
{
using (Cairo.Context ctx = new Cairo.Context (surface)) {
ctx.Rectangle ((int) x - 3, (int) y - 3, 6, 6);
ctx.Fill ();
}
QueueDrawArea ((int) x - 3, (int) y - 3, 6, 6);
}
开发者ID:liberostelios,项目名称:gtk-sharp,代码行数:9,代码来源:Scribble.cs
示例12: WithAlpha
public static Gdk.Pixbuf WithAlpha (this Gdk.Pixbuf image, double opacity)
{
using (var surf = new Cairo.ImageSurface (Cairo.Format.Argb32, image.Width, image.Height)) {
using (var g = new Cairo.Context (surf)) {
CairoHelper.SetSourcePixbuf (g, image, 0, 0);
g.PaintWithAlpha (opacity);
}
return new Gdk.Pixbuf (surf.Data, true, 8, surf.Width, surf.Height, surf.Stride);
}
}
开发者ID:msiyer,项目名称:Pinta,代码行数:11,代码来源:GdkExtensions.cs
示例13: Dispose
public void Dispose ()
{
if (Surface != null && Surface.Handle != IntPtr.Zero) {
((IDisposable)Surface).Dispose ();
}
Surface = null;
if (Context != null) {
Hyena.Gui.CairoExtensions.DisposeContext (Context);
Context = null;
}
}
开发者ID:GNOME,项目名称:pdfmod,代码行数:12,代码来源:PageThumbnail.cs
示例14: StreamGeometryContextImpl
public StreamGeometryContextImpl(Cairo.Path path = null)
{
_surf = new Cairo.ImageSurface (Cairo.Format.Argb32, 0, 0);
_context = new Cairo.Context (_surf);
this.Path = path;
if (this.Path != null)
{
_context.AppendPath(this.Path);
}
}
开发者ID:rdterner,项目名称:Perspex,代码行数:12,代码来源:StreamGeometryContextImpl.cs
示例15: Create
public override object Create(object img)
{
Gdk.Pixbuf pb = (Gdk.Pixbuf)img;
var imgs = new Cairo.ImageSurface (Cairo.Format.ARGB32, pb.Width, pb.Height);
var ic = new Cairo.Context (imgs);
Gdk.CairoHelper.SetSourcePixbuf (ic, pb, 0, 0);
ic.Paint ();
imgs.Flush ();
((IDisposable)ic).Dispose ();
var p = new Cairo.SurfacePattern (imgs);
p.Extend = Cairo.Extend.Repeat;
return p;
}
开发者ID:garuma,项目名称:xwt,代码行数:13,代码来源:ImagePatternBackendHandler.cs
示例16: CreateContext
public object CreateContext(Widget w)
{
GtkContext ctx = new GtkContext ();
var b = (IGtkWidgetBackend)WidgetRegistry.GetBackend (w);
if (!b.Widget.IsRealized) {
Cairo.Surface sf = new Cairo.ImageSurface (Cairo.Format.ARGB32, 1, 1);
Cairo.Context c = new Cairo.Context (sf);
ctx.Context = c;
ctx.TempSurface = sf;
} else {
ctx.Context = Gdk.CairoHelper.Create (b.Widget.GdkWindow);
}
return ctx;
}
开发者ID:chkn,项目名称:xwt,代码行数:14,代码来源:ContextBackendHandler.cs
示例17: UpdateThumbnail
private void UpdateThumbnail ()
{
double scalex = (double)Allocation.Width / (double)PintaCore.Workspace.ImageSize.Width;
double scaley = (double)Allocation.Height / (double)PintaCore.Workspace.ImageSize.Height;
thumbnail = new Cairo.ImageSurface (Cairo.Format.Argb32, Allocation.Width, Allocation.Height);
using (Cairo.Context g = new Cairo.Context (thumbnail)) {
g.Scale (scalex, scaley);
foreach (Layer layer in PintaCore.Layers.GetLayersToPaint ()) {
layer.Draw(g);
}
}
}
开发者ID:msiyer,项目名称:Pinta,代码行数:14,代码来源:PointPickerGraphic.cs
示例18: CairoPositionSnapshot
public CairoPositionSnapshot(ArrayList pos,
int width, int height)
{
fm = new FigureManager ();
Gtk.Window win =
new Gtk.Window (Gtk.WindowType.
Toplevel);
win.Realize ();
map = new Gdk.Pixmap (win.GdkWindow, width,
height);
cairo = Gdk.CairoHelper.Create (map);
FontDescription fontdesc =
GetFontDesc (width, height);
GetCoordLayoutDetails (win.PangoContext,
fontdesc);
border_color = new Cairo.Color (0, 0, 0);
// blacksq_color = new Gdk.Color (200, 200, 200);
// whitesq_color = new Gdk.Color (240, 240, 240);
blacksq_color =
new Cairo.Color (250 / 256.0,
120 / 256.0,
32 / 256.0);
whitesq_color =
new Cairo.Color (255 / 256.0,
250 / 256.0,
170 / 256.0);
background_color =
new Cairo.Color (1, 1, 1);
foreground_color =
new Cairo.Color (0, 0, 0);
// arrow_color = new Gdk.Color (159, 148, 249);
arrow_color =
new Cairo.Color (117 / 256.0,
6 / 256.0,
6 / 256.0);
// blacksq_color = new Gdk.Color(210, 60, 0);
// whitesq_color = new Gdk.Color(236, 193, 130);
// outer box, coord, inner box
ComputeSizes (width, height);
position = new Position (pos);
fm.SetSize (size);
DrawBackground ();
DrawPosition ();
}
开发者ID:BackupTheBerlios,项目名称:csboard-svn,代码行数:50,代码来源:CairoPositionSnapshot.cs
示例19: NativeCallback
public void NativeCallback (IntPtr cr, IntPtr attr, bool do_path, IntPtr data)
{
Cairo.Context mycr = null;
try {
mycr = new Cairo.Context (cr, false);
managed (mycr, Pango.Attribute.GetAttribute (attr), do_path);
if (release_on_call)
gch.Free ();
} catch (Exception e) {
GLib.ExceptionManager.RaiseUnhandledException (e, false);
}
}
开发者ID:akrisiun,项目名称:gtk-sharp,代码行数:14,代码来源:PangoSharp.CairoShapeRendererFuncNative.cs
示例20: TestDrawLine
public void TestDrawLine()
{
var bytes = new byte[1024 * 4];
var format = Cairo.Format.ARGB32;
var image = new Cairo.ImageSurface (bytes, format, 32, 32, 32 * 4);
var shape = new LineShape (0.0, 0.0, 32.0, 32.0);
var look = new Look (SolidBrush.Red, SolidPen.Black);
var op = new ShapeTree (look, shape);
using (var context = new Cairo.Context (image)) {
op.Draw (context);
}
image.WriteToPng ("testimages/line.png");
image.Dispose ();
}
开发者ID:bvssvni,项目名称:csharp-utils,代码行数:15,代码来源:TestDrawing.cs
注:本文中的Cairo.Context类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论