Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
 public void Clear(Color color)
 {
     SetColor(color);
     CContext.Operator = Operator.Source;
     CContext.Paint();
     CContext.Operator = Operator.Over;
 }
Ejemplo n.º 3
0
        public void DrawSurface(ISurface surface, Point p = null)
        {
            ImageSurface image;

            image = surface.Value as ImageSurface;
            if (p == null)
            {
                CContext.SetSourceSurface(image, 0, 0);
                CContext.Paint();
            }
            else
            {
                CContext.SetSourceSurface(image, (int)p.X, (int)p.Y);
                CContext.Rectangle(p.X, p.Y, image.Width, image.Height);
                CContext.Fill();
            }
        }
Ejemplo n.º 4
0
 public void DrawImage(Image image)
 {
     Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0);
     CContext.Paint();
 }