Beispiel #1
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();
        }