本文整理汇总了C#中Cairo.Context.Scale方法的典型用法代码示例。如果您正苦于以下问题:C# Cairo.Context.Scale方法的具体用法?C# Cairo.Context.Scale怎么用?C# Cairo.Context.Scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.Context
的用法示例。
在下文中一共展示了Cairo.Context.Scale方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
}
示例2: GetPattern
public Cairo.Pattern GetPattern(ApplicationContext actx, double scaleFactor)
{
if (pattern == null || currentScaleFactor != scaleFactor) {
if (pattern != null)
pattern.Dispose ();
Gdk.Pixbuf pb = ((GtkImage)Image.Backend).GetBestFrame (actx, scaleFactor, Image.Size.Width, Image.Size.Height, false);
var imgs = new Cairo.ImageSurface (Cairo.Format.ARGB32, (int)(Image.Size.Width * scaleFactor), (int)(Image.Size.Height * scaleFactor));
var ic = new Cairo.Context (imgs);
ic.Scale ((double)imgs.Width / (double)pb.Width, (double)imgs.Height / (double)pb.Height);
Gdk.CairoHelper.SetSourcePixbuf (ic, pb, 0, 0);
ic.Paint ();
imgs.Flush ();
((IDisposable)ic).Dispose ();
pattern = new Cairo.SurfacePattern (imgs);
pattern.Extend = Cairo.Extend.Repeat;
var cm = new Cairo.Matrix ();
cm.Scale (scaleFactor, scaleFactor);
pattern.Matrix = cm;
currentScaleFactor = scaleFactor;
}
return pattern;
}
示例3: BgBufferUpdate
public BgBufferUpdate (Minimpap mode)
{
this.mode = mode;
cr = Gdk.CairoHelper.Create (mode.backgroundBuffer);
cr.LineWidth = 1;
int w = mode.backgroundBuffer.ClipRegion.Clipbox.Width;
int h = mode.backgroundBuffer.ClipRegion.Clipbox.Height;
cr.Rectangle (0, 0, w, h);
if (mode.TextEditor.ColorStyle != null)
cr.Color = mode.TextEditor.ColorStyle.Default.CairoBackgroundColor;
cr.Fill ();
maxLine = mode.TextEditor.GetTextEditorData ().VisibleLineCount;
sx = w / (double)mode.TextEditor.Allocation.Width;
sy = Math.Min (1, lineHeight * maxLine / (double)mode.TextEditor.GetTextEditorData ().TotalHeight );
cr.Scale (sx, sy);
handler = GLib.Idle.Add (BgBufferUpdater);
}
示例4: OnDraw
void OnDraw (object data)
{
Action<Cairo.Context> callback = (Action<Cairo.Context>) data;
using (var context = new Cairo.Context (surface.Surface)) {
context.Operator = Cairo.Operator.Source;
context.SetSourceRGBA (0, 0, 0, 0);
context.Paint ();
context.Operator = Cairo.Operator.Over;
context.Scale (Scale, Scale);
callback (context);
}
runningSignal.Set ();
}
示例5: RenderFrame
Gdk.Pixbuf RenderFrame (ApplicationContext actx, double scaleFactor, double width, double height)
{
var swidth = Math.Max ((int)(width * scaleFactor), 1);
var sheight = Math.Max ((int)(height * scaleFactor), 1);
using (var sf = new Cairo.ImageSurface (Cairo.Format.ARGB32, swidth, sheight))
using (var ctx = new Cairo.Context (sf)) {
ImageDescription idesc = new ImageDescription () {
Alpha = 1,
Size = new Size (width, height)
};
ctx.Scale (scaleFactor, scaleFactor);
Draw (actx, ctx, scaleFactor, 0, 0, idesc);
var f = new ImageFrame (ImageBuilderBackend.CreatePixbuf (sf), Math.Max((int)width,1), Math.Max((int)height,1), true);
AddFrame (f);
return f.Pixbuf;
}
}
示例6: 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);
}
}
}
示例7: RenderFrame
Gdk.Pixbuf RenderFrame(ApplicationContext actx, double scaleFactor, ImageDescription idesc)
{
var swidth = Math.Max ((int)(idesc.Size.Width * scaleFactor), 1);
var sheight = Math.Max ((int)(idesc.Size.Height * scaleFactor), 1);
using (var sf = new Cairo.ImageSurface (Cairo.Format.ARGB32, swidth, sheight))
using (var ctx = new Cairo.Context (sf)) {
ctx.Scale (scaleFactor, scaleFactor);
Draw (actx, ctx, scaleFactor, 0, 0, idesc);
var f = new ImageFrame (ImageBuilderBackend.CreatePixbuf (sf), Math.Max ((int)idesc.Size.Width, 1), Math.Max ((int)idesc.Size.Height, 1), true);
if (drawCallback == null)
AddFrame (f);
return f.Pixbuf;
}
}