当前位置: 首页>>代码示例>>C#>>正文


C# IRenderContext.DrawImage方法代码示例

本文整理汇总了C#中IRenderContext.DrawImage方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderContext.DrawImage方法的具体用法?C# IRenderContext.DrawImage怎么用?C# IRenderContext.DrawImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRenderContext的用法示例。


在下文中一共展示了IRenderContext.DrawImage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Render

        /// <summary>
        /// Renders the image annotation.
        /// </summary>
        /// <param name="rc">
        /// The render context.
        /// </param>
        /// <param name="model">
        /// The plot model.
        /// </param>
        public override void Render(IRenderContext rc, PlotModel model)
        {
            base.Render(rc, model);

            var p = this.GetPoint(this.X, this.Y, rc, model);
            var o = this.GetVector(this.OffsetX, this.OffsetY, rc, model);
            var position = p + o;

            var clippingRect = this.GetClippingRect();

            var imageInfo = rc.GetImageInfo(this.ImageSource);
            if (imageInfo == null)
            {
                return;
            }

            var s = this.GetVector(this.Width, this.Height, rc, model);

            var width = s.X;
            var height = s.Y;

            if (double.IsNaN(width) && double.IsNaN(height))
            {
                width = imageInfo.Width;
                height = imageInfo.Height;
            }

            if (double.IsNaN(width))
            {
                width = height / imageInfo.Height * imageInfo.Width;
            }

            if (double.IsNaN(height))
            {
                height = width / imageInfo.Width * imageInfo.Height;
            }

            double x = position.X;
            double y = position.Y;

            if (this.HorizontalAlignment == HorizontalAlignment.Center)
            {
                x -= width * 0.5;
            }

            if (this.HorizontalAlignment == HorizontalAlignment.Right)
            {
                x -= width;
            }

            if (this.VerticalAlignment == VerticalAlignment.Middle)
            {
                y -= height * 0.5;
            }

            if (this.VerticalAlignment == VerticalAlignment.Bottom)
            {
                y -= height;
            }

            this.actualBounds = new OxyRect(x, y, width, height);

            if (this.X.Unit == PlotLengthUnit.Data || this.Y.Unit == PlotLengthUnit.Data)
            {
                rc.DrawClippedImage(clippingRect, this.ImageSource, x, y, width, height, this.Opacity, this.Interpolate);
            }
            else
            {
                rc.DrawImage(this.ImageSource, x, y, width, height, this.Opacity, this.Interpolate);
            }
        }
开发者ID:AndrewTPohlmann,项目名称:open-hardware-monitor,代码行数:80,代码来源:ImageAnnotation.cs

示例2: Render

        /// <summary>
        /// Renders the icon on the specified render context.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="size">The size.</param>
        public override void Render(IRenderContext rc, double size)
        {
            var n = (int)size * 2;
            var data = ArrayHelper.Evaluate(Functions.Peaks, ArrayHelper.CreateVector(-3.1, 2.6, n), ArrayHelper.CreateVector(3.0, -3.4, n));
            var palette = OxyPalettes.BlueWhiteRed(5);
            var min = data.Min2D();
            var max = data.Max2D();
            var pixels = new OxyColor[n, n];
            for (int x = 0; x < n; x++)
            {
                for (int y = 0; y < n; y++)
                {
                    var i = (int)((data[x, y] - min) / (max - min) * palette.Colors.Count);
                    i = Math.Min(Math.Max(i, 0), palette.Colors.Count - 1);
                    pixels[y, n - 1 - x] = palette.Colors[i];
                }
            }

            var image = OxyImage.Create(pixels, OxyPlot.ImageFormat.Png);
            rc.DrawImage(image, 0, 0, n, n, 0, 0, size, size, 1, true);

            var frameWidth = (int)Math.Max(Math.Round(size / 32), 1);
            rc.DrawRectangle(new OxyRect(0, 0, size, frameWidth), OxyColors.Black, OxyColors.Black, 0);
            rc.DrawRectangle(new OxyRect(0, size - frameWidth, size, frameWidth), OxyColors.Black, OxyColors.Undefined, 0);
            rc.DrawRectangle(new OxyRect(0, 0, frameWidth, size), OxyColors.Black, OxyColors.Undefined, 0);
            rc.DrawRectangle(new OxyRect(size - frameWidth, 0, frameWidth, size), OxyColors.Black, OxyColors.Undefined, 0);
        }
开发者ID:kleopatra999,项目名称:icon-generator,代码行数:32,代码来源:Program.cs

示例3: Render

        /// <summary>
        /// Renders the axis on the specified render context.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="pass">The render pass.</param>
        public override void Render(IRenderContext rc, int pass)
        {
            if (this.Position == AxisPosition.None)
            {
                return;
            }

            if (this.Palette == null)
            {
                throw new InvalidOperationException("No Palette defined for color axis.");
            }

            if (pass == 0)
            {
                double distance = this.AxisDistance;
                double left = this.PlotModel.PlotArea.Left;
                double top = this.PlotModel.PlotArea.Top;
                double width = this.MajorTickSize - 2;
                double height = this.MajorTickSize - 2;

                switch (this.Position)
                {
                    case AxisPosition.Left:
                        left = this.PlotModel.PlotArea.Left - this.PositionTierMinShift - width - distance;
                        top = this.PlotModel.PlotArea.Top;
                        break;
                    case AxisPosition.Right:
                        left = this.PlotModel.PlotArea.Right + this.PositionTierMinShift + distance;
                        top = this.PlotModel.PlotArea.Top;
                        break;
                    case AxisPosition.Top:
                        left = this.PlotModel.PlotArea.Left;
                        top = this.PlotModel.PlotArea.Top - this.PositionTierMinShift - height - distance;
                        break;
                    case AxisPosition.Bottom:
                        left = this.PlotModel.PlotArea.Left;
                        top = this.PlotModel.PlotArea.Bottom + this.PositionTierMinShift + distance;
                        break;
                }

                if (this.RenderAsImage)
                {
                    var axisLength = this.Transform(this.ActualMaximum) - this.Transform(this.ActualMinimum);
                    bool reverse = axisLength > 0;
                    axisLength = Math.Abs(axisLength);

                    if (this.IsHorizontal())
                    {
                        var colorAxisImage = this.GenerateColorAxisImage(reverse);
                        rc.DrawImage(colorAxisImage, left, top, axisLength, height, 1, true);
                    }
                    else
                    {
                        var colorAxisImage = this.GenerateColorAxisImage(reverse);
                        rc.DrawImage(colorAxisImage, left, top, width, axisLength, 1, true);
                    }
                }
                else
                {
                    Action<double, double, OxyColor> drawColorRect = (ylow, yhigh, color) =>
                                       {
                                           double ymin = Math.Min(ylow, yhigh);
                                           double ymax = Math.Max(ylow, yhigh) + 0.5;
                                           rc.DrawRectangle(
                                               this.IsHorizontal()
                                                   ? new OxyRect(ymin, top, ymax - ymin, height)
                                                   : new OxyRect(left, ymin, width, ymax - ymin),
                                               color,
                                               OxyColors.Undefined);
                                       };

                    int n = this.Palette.Colors.Count;
                    for (int i = 0; i < n; i++)
                    {
                        double ylow = this.Transform(this.GetLowValue(i));
                        double yhigh = this.Transform(this.GetHighValue(i));
                        drawColorRect(ylow, yhigh, this.Palette.Colors[i]);
                    }

                    double highLowLength = 10;
                    if (this.IsHorizontal())
                    {
                        highLowLength *= -1;
                    }

                    if (!this.LowColor.IsUndefined())
                    {
                        double ylow = this.Transform(this.ActualMinimum);
                        drawColorRect(ylow, ylow + highLowLength, this.LowColor);
                    }

                    if (!this.HighColor.IsUndefined())
                    {
                        double yhigh = this.Transform(this.ActualMaximum);
                        drawColorRect(yhigh, yhigh - highLowLength, this.HighColor);
//.........这里部分代码省略.........
开发者ID:Keyabob,项目名称:MMG,代码行数:101,代码来源:LinearColorAxis.cs


注:本文中的IRenderContext.DrawImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。