예제 #1
0
        public override void DrawImage(GraphicsHandler graphics, int x, int y)
        {
            var nsimage  = this.Control;
            var destRect = graphics.TranslateView(Generator.ConvertF(new Rectangle(x, y, (int)nsimage.Size.Width, (int)nsimage.Size.Height)), false);

            nsimage.Draw(destRect, CGBlendMode.Normal, 1);
        }
예제 #2
0
        /*
         * public override void DrawImage (GraphicsHandler graphics, int x, int y, int width, int height)
         * {
         *      var nsimage = this.Control;
         *      var sourceRect = graphics.Translate(new SD.RectangleF(0, 0, nsimage.Size.Width, nsimage.Size.Height), nsimage.Size.Height);
         *      var destRect = graphics.TranslateView(new SD.RectangleF(x, y, width, height), false);
         *      nsimage.Draw(destRect, sourceRect, NSCompositingOperation.SourceOver, 1);
         * }
         */

        public override void DrawImage(GraphicsHandler graphics, Rectangle source, Rectangle destination)
        {
            var nsimage    = this.Control;
            var sourceRect = Generator.ConvertF(source);

            //var sourceRect = graphics.Translate(Generator.ConvertF(source), nsimage.Size.Height);
            SD.RectangleF destRect = graphics.TranslateView(Generator.ConvertF(destination), false);
            if (source.TopLeft != Point.Empty || sourceRect.Size != nsimage.Size)
            {
                graphics.Context.SaveState();
                //graphics.Context.ClipToRect(destRect);
                if (!graphics.Flipped)
                {
                    graphics.Context.TranslateCTM(0, nsimage.Size.Height);
                    graphics.Context.ScaleCTM(nsimage.Size.Width / destRect.Width, -(nsimage.Size.Height / destRect.Height));
                }
                else
                {
                    graphics.Context.ScaleCTM(nsimage.Size.Width / destRect.Width, nsimage.Size.Height / destRect.Height);
                }
                graphics.Context.DrawImage(new SD.RectangleF(SD.PointF.Empty, destRect.Size), nsimage.CGImage);
                //nsimage.CGImage(destRect, CGBlendMode.Normal, 1);

                graphics.Context.RestoreState();

                //var imgportion = nsimage..CGImage.WithImageInRect(sourceRect);

                /*graphics.Context.SaveState();
                 * if (graphics.Flipped) {
                 *      graphics.Context.TranslateCTM(0, destRect.Bottom);
                 *      graphics.Context.ScaleCTM(1.0F, -1.0F);
                 * }*/
                //var context = graphics.ControlObject as CGContext;
                //Console.WriteLine("drawing source:{0} dest:{1}", source, destRect);
                //graphics.Context.DrawImage(destRect, imgportion);

                //nsimage = UIImage.FromImage(imgportion);
                //nsimage.Draw(destRect, CGBlendMode.Normal, 1);

                //imgportion.Dispose();
                //nsimage.Dispose();
                //graphics.Context.RestoreState();
            }
            else
            {
                //graphics.Context.DrawImage(destRect, nsimage.CGImage);
                //Console.WriteLine("drawing full image");
                nsimage.Draw(destRect, CGBlendMode.Normal, 1);
            }
        }
예제 #3
0
파일: IconHandler.cs 프로젝트: sami1971/Eto
        public override void DrawImage(GraphicsHandler graphics, RectangleF source, RectangleF destination)
        {
            var sourceRect = source.ToSD();
            var imgsize    = Control.Size;

            SD.RectangleF destRect = graphics.TranslateView(destination.ToSD(), false);
            if (source.TopLeft != Point.Empty || sourceRect.Size != imgsize)
            {
                graphics.Control.TranslateCTM(destRect.X - sourceRect.X, imgsize.Height - (destRect.Y - sourceRect.Y));
                graphics.Control.ScaleCTM(imgsize.Width / sourceRect.Width, -(imgsize.Height / sourceRect.Height));
                graphics.Control.DrawImage(new SD.RectangleF(SD.PointF.Empty, destRect.Size), Control.CGImage);
            }
            else
            {
                Control.Draw(destRect, CGBlendMode.Normal, 1);
            }
        }