public static Cairo.Region RegionCreateFromSurface(Cairo.Surface surface) { IntPtr raw_ret = gdk_cairo_region_create_from_surface(surface.Handle); Cairo.Region ret = new Cairo.Region(raw_ret); return(ret); }
public static Cairo.Surface SurfaceCreateFromPixbuf(Gdk.Pixbuf pixbuf, int scale, Gdk.Window for_window) { IntPtr raw_ret = gdk_cairo_surface_create_from_pixbuf(pixbuf == null ? IntPtr.Zero : pixbuf.Handle, scale, for_window == null ? IntPtr.Zero : for_window.Handle); Cairo.Surface ret = Cairo.Surface.Lookup(raw_ret, true); return(ret); }
public Cairo.Surface GetSurface(out double x_hot, out double y_hot) { IntPtr raw_ret = gdk_cursor_get_surface(Handle, out x_hot, out y_hot); Cairo.Surface ret = Cairo.Surface.Lookup(raw_ret, true); return(ret); }
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); } }
public Cairo.Surface RenderIconSurface(Gtk.StyleContext context, Gtk.IconSize size, int scale, Gdk.Window for_window) { IntPtr raw_ret = gtk_icon_set_render_icon_surface(Handle, context == null ? IntPtr.Zero : context.Handle, (int)size, scale, for_window == null ? IntPtr.Zero : for_window.Handle); Cairo.Surface ret = Cairo.Surface.Lookup(raw_ret, true); return(ret); }
public static Cairo.Surface GetSurface(Gdk.Window window) { IntPtr raw_ret = gdk_offscreen_window_get_surface(window == null ? IntPtr.Zero : window.Handle); Cairo.Surface ret = Cairo.Surface.Lookup(raw_ret, true); return(ret); }
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); } }
public override object CreateContext(object backend) { Cairo.Surface sf = (Cairo.Surface)backend; CairoContextBackend ctx = new CairoContextBackend(1); ctx.Context = new Cairo.Context(sf); return(ctx); }
public virtual void End() { if (d_surface != null) { d_surface.Destroy(); d_surface = null; } }
public object CreateContext(object backend) { Cairo.Surface sf = (Cairo.Surface)backend; GtkContext ctx = new GtkContext(); ctx.Context = new Cairo.Context(sf); return(ctx); }
public Image(Cairo.Surface surface) : base(IntPtr.Zero) { if (GetType() != typeof(Image)) { var vals = new List <GLib.Value> (); var names = new List <string> (); CreateNativeObject(names.ToArray(), vals.ToArray()); return; } Raw = gtk_image_new_from_surface(surface.Handle); }
protected override bool OnConfigureEvent(EventConfigure ev) { if (surface != null) { surface.Dispose(); } surface = ev.Window.CreateSimilarSurface(Cairo.Content.Color, AllocatedWidth, AllocatedHeight); ClearSurface(); return(true); }
public unsafe Cairo.Surface LoadSurface(Gdk.Window for_window) { IntPtr error = IntPtr.Zero; IntPtr raw_ret = gtk_icon_info_load_surface(Handle, for_window == null ? IntPtr.Zero : for_window.Handle, out error); Cairo.Surface ret = Cairo.Surface.Lookup(raw_ret, true); if (error != IntPtr.Zero) { throw new GLib.GException(error); } return(ret); }
public unsafe Cairo.Surface GetSurface() { IntPtr error = IntPtr.Zero; IntPtr raw_ret = gtk_print_job_get_surface(Handle, out error); Cairo.Surface ret = Cairo.Surface.Lookup(raw_ret, true); if (error != IntPtr.Zero) { throw new GLib.GException(error); } return(ret); }
/// <summary> /// Loads pixbuf resource from store, if specified pixbuf is not already loaded in /// store, then this methods loads it from list of resources and registers it /// </summary> /// <param name="aWidget"> /// Extension method per cairo surface <see cref="Gtk.Widget"/> /// </param> /// <param name="aName"> /// Resource name <see cref="System.String"/> /// </param> /// <returns> /// Result pixbuf <see cref="Gdk.Pixbuf"/> /// </returns> public static Gdk.Pixbuf LoadPixbufFromResourceStore(this Cairo.Surface aCell, string aName) { if (PictureResourceStore.Get(aName) != null) { return((Gdk.Pixbuf)PictureResourceStore.Get(aName)); } Gdk.Pixbuf pix = new Gdk.Pixbuf(AssemblyEngine.EntryAssembly.LoadBinaryResource(aName)); if (pix != null) { PictureResourceStore.Add(aName, pix); } return(pix); }
private bool InternalTextureFromSurface(Cairo.Surface surface, Cairo.Region region) { TextureFromSurfaceNativeDelegate unmanaged = class_abi.BaseOverride <TextureFromSurfaceNativeDelegate>(this.LookupGType(), "texture_from_surface"); if (unmanaged == null) { return(false); } bool __result = unmanaged(this.Handle, surface.Handle, region == null ? IntPtr.Zero : region.Handle); return(__result); }
protected override bool OnDrawn(Cairo.Context cr) { if (!base.OnDrawn(cr)) { return(false); } if (ViewObjects) { using (Cairo.Surface source = CairoHelper.LockBitmap(Image)) { cr.SetSourceSurface(source, XOffset, YOffset); cr.Paint(); CairoHelper.UnlockBitmap(Image); } } else { base.OnDrawn(cr); } if (ViewObjects && objectEditor != null) { // Draw objects int cursorX = -1, cursorY = -1; int selectedX = -1, selectedY = -1; hoveringObjectIndices = new List <int>(); ObjectGroup group = objectEditor.ObjectGroup; DrawObjectGroup(cr, 0, ref cursorX, ref cursorY, ref selectedX, ref selectedY, group, objectEditor, ref hoveringObjectIndices); // Object hovering over if (cursorX != -1) { cr.Rectangle(cursorX + 0.5, cursorY + 0.5, 15, 15); cr.SetSourceColor(TileGridViewer.HoverColor); cr.LineWidth = 1; cr.Stroke(); } // Object selected if (selectedX != -1) { cr.Rectangle(selectedX + 0.5, selectedY + 0.5, 15, 15); cr.SetSourceColor(TileGridSelector.SelectionColor); cr.LineWidth = 1; cr.Stroke(); } } return(true); }
public unsafe Cairo.Surface LoadSurface(string icon_name, int size, int scale, Gdk.Window for_window, Gtk.IconLookupFlags flags) { IntPtr native_icon_name = GLib.Marshaller.StringToPtrGStrdup(icon_name); IntPtr error = IntPtr.Zero; IntPtr raw_ret = gtk_icon_theme_load_surface(Handle, native_icon_name, size, scale, for_window == null ? IntPtr.Zero : for_window.Handle, (int)flags, out error); Cairo.Surface ret = Cairo.Surface.Lookup(raw_ret, true); GLib.Marshaller.Free(native_icon_name); if (error != IntPtr.Zero) { throw new GLib.GException(error); } return(ret); }
public static Gdk.Pixbuf GetFromSurface(Cairo.Surface surface, int src_x, int src_y, int width, int height) { IntPtr raw_ret = gdk_pixbuf_get_from_surface(surface.Handle, src_x, src_y, width, height); Gdk.Pixbuf ret; if (raw_ret == IntPtr.Zero) { ret = null; } else { ret = (Gdk.Pixbuf)GLib.Object.GetObject(raw_ret); } return(ret); }
public Cursor(Gdk.Display display, Cairo.Surface surface, double x, double y) : base(IntPtr.Zero) { if (GetType() != typeof(Cursor)) { var vals = new List <GLib.Value> (); var names = new List <string> (); if (display != null) { names.Add("display"); vals.Add(new GLib.Value(display)); } CreateNativeObject(names.ToArray(), vals.ToArray()); return; } Raw = gdk_cursor_new_from_surface(display == null ? IntPtr.Zero : display.Handle, surface.Handle, x, y); }
private bool InternalTextureFromSurface(Cairo.Surface surface, Cairo.Region region) { TextureFromSurfaceNativeDelegate unmanaged = null; unsafe { IntPtr *raw_ptr = (IntPtr *)(((long)this.LookupGType().GetThresholdType().GetClassPtr()) + (long)class_abi.GetFieldOffset("texture_from_surface")); unmanaged = (TextureFromSurfaceNativeDelegate)Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(TextureFromSurfaceNativeDelegate)); } if (unmanaged == null) { return(false); } bool __result = unmanaged(this.Handle, surface.Handle, region == null ? IntPtr.Zero : region.Handle); return(__result); }
protected void placeShapes() { if (_surface != null) { drawingArea.GdkWindow.Clear(); _surface.Dispose(); _surface = null; } _min = Vertex.CreateMax(); _max = Vertex.CreateMin(); foreach (AbstractShape shape in _shapes) { _min.Minimize(shape.Min); _max.Maximize(shape.Max); log("фигура {0} расположена на позиции от {1} до {2}", shape, shape.Min.Literal, shape.Max.Literal); } _min -= _lineWidthGap; _max += _lineWidthGap; _logicCanvasSize = _max - _min; log("размер логического холста (с учётом толщины линий) - {0}", _logicCanvasSize.Literal); _logicCanvasSize *= _prescale; _surface = new Cairo.ImageSurface(Cairo.Format.Argb32, ( int )_logicCanvasSize.X, ( int )_logicCanvasSize.Y); using (var surfaceContext = new Cairo.Context(_surface)) { surfaceContext.SetSourceRGB(1.0, 1.0, 1.0); surfaceContext.Paint(); surfaceContext.LineWidth = 1.0; surfaceContext.SetSourceRGB(.0, .0, .0); surfaceContext.Scale(_prescale, -_prescale); surfaceContext.Translate(-_min.X, -_max.Y); if (null != _shapes && 0 < _shapes.Count) { foreach (AbstractShape shape in _shapes) { shape.Draw(surfaceContext); surfaceContext.Stroke(); } } } }
private void OnWidgetDestroyed(object sender, EventArgs args) { if (!IsRealized) { return; } // Copy the widget's pixels to surface, we'll use it to draw the animation surface = Window.CreateSimilarSurface(Cairo.Content.ColorAlpha, widget_alloc.Width, widget_alloc.Height); using (var cr = new Cairo.Context(surface)) { Gdk.CairoHelper.SetSourceWindow(cr, Window, widget_alloc.X, widget_alloc.Y); cr.Rectangle(0, 0, widget_alloc.Width, widget_alloc.Height); cr.Fill(); if (AnimationState != AnimationState.Going) { WidgetDestroyed(this, args); } } }
// 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; }
protected virtual Cairo.Surface CreateGraphSurface(int width, int height) { Cairo.Surface ret = null; using (Cairo.Context ctx = Gdk.CairoHelper.Create(GdkWindow)) { Cairo.Surface surface; if (Screen.RgbaColormap != null) { surface = ctx.Target.CreateSimilar(Cairo.Content.ColorAlpha, width, height); } else { surface = ctx.Target.CreateSimilar(ctx.Target.Content, width, height); } ret = surface; ((IDisposable)ctx.Target).Dispose(); } return(ret); }
/// <summary> /// Will throw InvalidAnimationException if initialization failed earlier... /// TODO: does drawing code really belong here? /// </summary> public void Draw(Cairo.Context cr, int xPos, int yPos) { if (bitmaps == null) { throw new InvalidAnimationException(); } int _numSprites = _oamData.GetIntValue(0); // Draw sprites in backwards order to respect priority properly for (int i = _numSprites - 1; i >= 0; i--) { Tuple <Bitmap, int, int> tup = bitmaps[i]; Bitmap bitmap = tup.Item1; int x = tup.Item2 + xPos; int y = tup.Item3 + yPos; using (Cairo.Surface s = CairoHelper.LockBitmap(bitmap)) { cr.SetSourceSurface(s, x, y); cr.Paint(); CairoHelper.UnlockBitmap(bitmap); } } }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build(); // настройка элементов интерфейса _statusBarContext = statusBar.GetContextId("statusbar - ctx"); viewLogText.Editable = false; drawingArea.AddEvents(( int )Gdk.EventMask.PointerMotionMask); // параметры "реального" холста drawingArea.ModifyBg(StateType.Normal, new Gdk.Color(0xff, 0xff, 0xff)); drawingArea.ModifyBase(StateType.Normal, new Gdk.Color(0x00, 0x00, 0x00)); // параметры виртуального холста _prescale = 20.0; _lineWidth = 1.0; _lineWidthGap = new Vertex(_lineWidth, _lineWidth); _surface = null; _shapes = null; // настройка парсера initParser(); log("начало работы программы"); }
protected override bool OnConfigureEvent (EventConfigure ev) { if (surface != null) { surface.Dispose (); } surface = ev.Window.CreateSimilarSurface (Cairo.Content.Color, AllocatedWidth, AllocatedHeight); ClearSurface (); return true; }
private void OnWidgetDestroyed(object sender, EventArgs args) { if (!IsRealized) { return; } // Copy the widget's pixels to surface, we'll use it to draw the animation surface = Window.CreateSimilarSurface (Cairo.Content.ColorAlpha, widget_alloc.Width, widget_alloc.Height); using (var cr = new Cairo.Context (surface)) { Gdk.CairoHelper.SetSourceWindow (cr, Window, widget_alloc.X, widget_alloc.Y); cr.Rectangle (0, 0, widget_alloc.Width, widget_alloc.Height); cr.Fill (); if (AnimationState != AnimationState.Going) { WidgetDestroyed (this, args); } } }
public static void IconSurface(Gtk.StyleContext context, Cairo.Context cr, Cairo.Surface surface, double x, double y) { gtk_render_icon_surface(context == null ? IntPtr.Zero : context.Handle, cr == null ? IntPtr.Zero : cr.Handle, surface.Handle, x, y); }
// 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; }
/// <summary> /// Initializes a new instance of the <see cref="DrawingContext"/> class. /// </summary> /// <param name="surface">The target surface.</param> public DrawingContext(Cairo.Surface surface) { _context = new Cairo.Context(surface); CurrentTransform = Matrix.Identity; }
public Graphics(Cairo.Surface surface) : base(default(Cairo.Surface)) { }
public Context(Cairo.Surface surface) { }