本文整理汇总了C#中Cairo.Context.SetSourceSurface方法的典型用法代码示例。如果您正苦于以下问题:C# Cairo.Context.SetSourceSurface方法的具体用法?C# Cairo.Context.SetSourceSurface怎么用?C# Cairo.Context.SetSourceSurface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.Context
的用法示例。
在下文中一共展示了Cairo.Context.SetSourceSurface方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public void Start (BaseEffect effect)
{
if (live_preview_enabled)
throw new InvalidOperationException ("LivePreviewManager.Start() called while live preview is already enabled.");
// Create live preview surface.
// Start rendering.
// Listen for changes to effectConfiguration object, and restart render if needed.
live_preview_enabled = true;
apply_live_preview_flag = false;
cancel_live_preview_flag = false;
layer = PintaCore.Layers.CurrentLayer;
this.effect = effect;
// Handle selection path.
PintaCore.Tools.Commit ();
selection_path = (PintaCore.Layers.ShowSelection) ? PintaCore.Workspace.ActiveDocument.Selection.SelectionPath : null;
render_bounds = selection_path.GetBounds ();
render_bounds = PintaCore.Workspace.ClampToImageSize (render_bounds);
//TODO Use the current tool layer instead.
live_preview_surface = new Cairo.ImageSurface (Cairo.Format.Argb32,
PintaCore.Workspace.ImageSize.Width,
PintaCore.Workspace.ImageSize.Height);
// Paint the pre-effect layer surface into into the working surface.
using (var ctx = new Cairo.Context (live_preview_surface)) {
ctx.SetSourceSurface (layer.Surface, (int) layer.Offset.X, (int) layer.Offset.Y);
ctx.Paint ();
}
if (effect.EffectData != null)
effect.EffectData.PropertyChanged += EffectData_PropertyChanged;
if (Started != null) {
Started (this, new LivePreviewStartedEventArgs());
}
var settings = new AsyncEffectRenderer.Settings () {
ThreadCount = PintaCore.System.RenderThreads,
TileWidth = render_bounds.Width,
TileHeight = 1,
ThreadPriority = ThreadPriority.BelowNormal
};
Debug.WriteLine (DateTime.Now.ToString("HH:mm:ss:ffff") + "Start Live preview.");
renderer = new Renderer (this, settings);
renderer.Start (effect, layer.Surface, live_preview_surface, render_bounds);
if (effect.IsConfigurable) {
if (!effect.LaunchConfiguration ()) {
PintaCore.Chrome.MainWindowBusy = true;
Cancel ();
} else {
PintaCore.Chrome.MainWindowBusy = true;
Apply ();
}
} else {
PintaCore.Chrome.MainWindowBusy = true;
Apply ();
}
}
示例2: CreateOffsetLayer
private Layer CreateOffsetLayer(Layer original)
{
var offset = OffsetLayer;
offset.Surface.Clear ();
using (var g = new Cairo.Context (offset.Surface)) {
g.SetSourceSurface (original.Surface, (int)original.Offset.X, (int)original.Offset.Y);
g.Paint ();
}
offset.BlendMode = original.BlendMode;
offset.Offset = original.Offset;
offset.Opacity = original.Opacity;
return offset;
}
示例3: HandleApply
// Called from asynchronously from Renderer.OnCompletion ()
void HandleApply ()
{
Debug.WriteLine ("LivePreviewManager.HandleApply()");
var item = new SimpleHistoryItem (effect.Icon, effect.Name);
item.TakeSnapshotOfLayer (PintaCore.Layers.CurrentLayerIndex);
using (var ctx = new Cairo.Context (layer.Surface)) {
ctx.Save ();
ctx.AppendPath (PintaCore.Workspace.ActiveDocument.Selection.SelectionPath);
ctx.FillRule = Cairo.FillRule.EvenOdd;
ctx.Clip ();
ctx.Operator = Cairo.Operator.Source;
ctx.SetSourceSurface (live_preview_surface, (int)layer.Offset.X, (int)layer.Offset.Y);
ctx.Paint ();
ctx.Restore ();
}
PintaCore.History.PushNewItem (item);
FireLivePreviewEndedEvent(RenderStatus.Completed, null);
live_preview_enabled = false;
PintaCore.Workspace.Invalidate (); //TODO keep track of dirty bounds.
CleanUp ();
}
示例4: 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 ()) {
g.SetSourceSurface (layer.Surface, (int)layer.Offset.X, (int)layer.Offset.Y);
g.PaintWithAlpha (layer.Opacity);
}
}
}