예제 #1
0
        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();
        }
예제 #2
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();
        }
예제 #3
0
        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();
        }