public void DrawImage(Point start, double width, double height, Image image, bool scale, bool masked = false) { double scaleX, scaleY; Point offset; if (scale) { image.ScaleFactor((int)width, (int)height, out scaleX, out scaleY, out offset); } else { offset = new Point(0, 0); scaleX = width / image.Width; scaleY = height / image.Height; } CContext.Save(); CContext.Translate(start.X + offset.X, start.Y + offset.Y); CContext.Scale(scaleX, scaleY); if (masked) { CContext.PushGroup(); Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0); CContext.Paint(); var src = CContext.PopGroup(); SetColor(FillColor); CContext.Mask(src); src.Dispose(); } else { Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0); CContext.Paint(); } CContext.Restore(); }
public void DrawSurface(Point start, double width, double height, ISurface surface, ScaleMode mode, bool masked = false) { //FIXME: This still needs support for masked surfaces double scaleX, scaleY; Point offset; BaseImage <Pixbuf> .ScaleFactor((int)(surface.Width *surface.DeviceScaleFactor), (int)(surface.Height *surface.DeviceScaleFactor), (int)width, (int)height, mode, out scaleX, out scaleY, out offset); CContext.Save(); CContext.Translate(offset.X + start.X, offset.Y + start.Y); CContext.Scale(scaleX, scaleY); if (masked) { CContext.PushGroup(); } ImageSurface image = surface.Value as ImageSurface; CContext.SetSourceSurface(image, 0, 0); CContext.Rectangle(0, 0, image.Width, image.Height); CContext.Fill(); if (masked) { var src = CContext.PopGroup(); SetColor(FillColor); CContext.Mask(src); src.Dispose(); } CContext.Restore(); }
public void DrawImage(Point start, double width, double height, Image image, ScaleMode mode, bool masked = false, float alpha = 1) { double scaleX, scaleY; Point offset; BaseImage <Pixbuf> .ScaleFactor((int)(image.Width *image.DeviceScaleFactor), (int)(image.Height *image.DeviceScaleFactor), (int)width, (int)height, mode, out scaleX, out scaleY, out offset); CContext.Save(); CContext.Translate(start.X + offset.X, start.Y + offset.Y); CContext.Scale(scaleX, scaleY); if (masked) { CContext.PushGroup(); Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0); CContext.PaintWithAlpha(alpha); var src = CContext.PopGroup(); SetColor(FillColor); CContext.Mask(src); src.Dispose(); } else { Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0); CContext.PaintWithAlpha(alpha); } CContext.Restore(); }
public void DrawCircleImage(Point center, double radius, Image image) { DrawCircle(center, radius); CContext.Save(); CContext.Arc(center.X, center.Y, radius, 0, 2 * Math.PI); CContext.Clip(); DrawImage(new Point(center.X - radius, center.Y - radius), radius * 2, radius * 2, image, ScaleMode.AspectFill, false); CContext.Restore(); }
public void DrawEllipse(Point center, double axisX, double axisY) { double max = Math.Max(axisX, axisY); CContext.Save(); CContext.Translate(center.X, center.Y); CContext.Scale(axisX / max, axisY / max); CContext.Arc(0, 0, max, 0, 2 * Math.PI); StrokeAndFill(); CContext.Restore(); }
public void Begin() { savedStrokeColor = StrokeColor; savedFillColor = FillColor; savedFSlant = fSlant; savedFWeight = fWeight; savedAlignment = fAlignment; savedLineWidth = LineWidth; savedFontSize = FontSize; savedFontFamily = FontFamily; savedLineStyle = LineStyle; savedClear = ClearOperation; CContext.Save(); }
public void Begin() { contextStatus.Push(new ContextStatus( StrokeColor, FillColor, fSlant, fWeight, fAlignment, LineWidth, FontSize, FontFamily, LineStyle, ClearOperation )); CContext.Save(); }