本文整理汇总了C#中IRenderContext.DrawClippedImage方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderContext.DrawClippedImage方法的具体用法?C# IRenderContext.DrawClippedImage怎么用?C# IRenderContext.DrawClippedImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRenderContext
的用法示例。
在下文中一共展示了IRenderContext.DrawClippedImage方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
/// <summary>
/// Renders the series on the specified render context.
/// </summary>
/// <param name="rc">The rendering context.</param>
/// <param name="model">The model.</param>
public override void Render(IRenderContext rc, PlotModel model)
{
if (this.Matrix == null)
{
return;
}
int m = this.Matrix.GetLength(0);
int n = this.Matrix.GetLength(1);
var p0 = this.Transform(0, 0);
var p1 = this.Transform(n, m);
if (this.image == null)
{
var pixels = new OxyColor[m, n];
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
pixels[i, j] = Math.Abs(this.Matrix[m - 1 - i, j]) <= this.ZeroTolerance ? OxyColors.Transparent : this.NotZeroColor;
}
}
this.image = OxyImage.PngFromArgb(pixels);
}
var clip = this.GetClippingRect();
var x0 = Math.Min(p0.X, p1.X);
var y0 = Math.Min(p0.Y, p1.Y);
var w = Math.Abs(p0.X - p1.X);
var h = Math.Abs(p0.Y - p1.Y);
rc.DrawClippedImage(clip, this.image, x0, y0, w, h, 1, false);
var points = new List<ScreenPoint>();
if (this.GridInterval > 0)
{
var p2 = this.Transform(this.GridInterval, this.GridInterval);
if (Math.Abs(p2.Y - p0.Y) > this.MinimumGridLineDistance)
{
for (int i = 1; i < n; i += this.GridInterval)
{
points.Add(this.Transform(0, i));
points.Add(this.Transform(n, i));
}
}
if (Math.Abs(p2.X - p0.X) > this.MinimumGridLineDistance)
{
for (int j = 1; j < m; j += this.GridInterval)
{
points.Add(this.Transform(j, 0));
points.Add(this.Transform(j, m));
}
}
}
if (this.ShowDiagonal)
{
points.Add(this.Transform(0, 0));
points.Add(this.Transform(n, m));
}
rc.DrawClippedLineSegments(points, clip, this.GridColor, 1, LineStyle.Solid, OxyPenLineJoin.Miter, true);
if (this.BorderColor != null)
{
var borderPoints = new List<ScreenPoint>
{
this.Transform(0, 0),
this.Transform(m, 0),
this.Transform(0, n),
this.Transform(m, n),
this.Transform(0, 0),
this.Transform(0, n),
this.Transform(m, 0),
this.Transform(m, n)
};
rc.DrawClippedLineSegments(
borderPoints, clip, this.BorderColor, 1, LineStyle.Solid, OxyPenLineJoin.Miter, true);
}
}
示例2: Render
/// <summary>
/// Renders the annotation on the specified context.
/// </summary>
/// <param name="rc">The render context.</param>
public override void Render(IRenderContext rc)
{
base.Render(rc);
var lon0 = this.XAxis.ActualMinimum;
var lon1 = this.XAxis.ActualMaximum;
var lat0 = this.YAxis.ActualMinimum;
var lat1 = this.YAxis.ActualMaximum;
// the desired number of tiles horizontally
double tilesx = this.PlotModel.Width / this.TileSize;
// calculate the desired zoom level
var n = tilesx / (((lon1 + 180) / 360) - ((lon0 + 180) / 360));
var zoom = (int)Math.Round(Math.Log(n) / Math.Log(2));
if (zoom < this.MinZoomLevel)
{
zoom = this.MinZoomLevel;
}
if (zoom > this.MaxZoomLevel)
{
zoom = this.MaxZoomLevel;
}
// find tile coordinates for the corners
double x0, y0;
LatLonToTile(lat0, lon0, zoom, out x0, out y0);
double x1, y1;
LatLonToTile(lat1, lon1, zoom, out x1, out y1);
double xmax = Math.Max(x0, x1);
double xmin = Math.Min(x0, x1);
double ymax = Math.Max(y0, y1);
double ymin = Math.Min(y0, y1);
var clippingRectangle = this.GetClippingRect();
// Add the tiles
for (var x = (int)xmin; x < xmax; x++)
{
for (var y = (int)ymin; y < ymax; y++)
{
string uri = this.GetTileUri(x, y, zoom);
var img = this.GetImage(uri, rc.RendersToScreen);
if (img == null)
{
continue;
}
// transform from tile coordinates to lat/lon
double latitude0, latitude1, longitude0, longitude1;
TileToLatLon(x, y, zoom, out latitude0, out longitude0);
TileToLatLon(x + 1, y + 1, zoom, out latitude1, out longitude1);
// transform from lat/lon to screen coordinates
var s00 = this.Transform(longitude0, latitude0);
var s11 = this.Transform(longitude1, latitude1);
var r = OxyRect.Create(s00.X, s00.Y, s11.X, s11.Y);
// draw the image
rc.DrawClippedImage(clippingRectangle, img, r.Left, r.Top, r.Width, r.Height, this.Opacity, true);
}
}
// draw the copyright notice
var p = new ScreenPoint(clippingRectangle.Right - 5, clippingRectangle.Bottom - 5);
var textSize = rc.MeasureText(this.CopyrightNotice, this.ActualFont, this.ActualFontSize, this.ActualFontWeight);
rc.DrawRectangle(new OxyRect(p.X - textSize.Width - 2, p.Y - textSize.Height - 2, textSize.Width + 4, textSize.Height + 4), OxyColor.FromAColor(200, OxyColors.White), OxyColors.Undefined);
rc.DrawText(
p,
this.CopyrightNotice,
OxyColors.Black,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
0,
HorizontalAlignment.Right,
VerticalAlignment.Bottom);
}
示例3: RenderFixed
/// <summary>
/// Renders by scaling a fixed image.
/// </summary>
/// <param name="rc">The render context.</param>
/// <param name="model">The model.</param>
public void RenderFixed(IRenderContext rc, PlotModel model)
{
if (image == null)
{
int m = this.Data.GetLength(0);
int n = this.Data.GetLength(1);
int width = this.ImageSize;
int height = this.ImageSize;
if (this.pixels == null || this.pixels.GetLength(0) != height || this.pixels.GetLength(1) != width)
{
this.pixels = new OxyColor[width, height];
}
var p = this.pixels;
for (int yi = 0; yi < height; yi++)
{
for (int xi = 0; xi < width; xi++)
{
double x = (xi - width * 0.5) / (width * 0.5) * this.Magnitude1;
double y = -(yi - height * 0.5) / (height * 0.5) * this.Magnitude1;
double angle = Math.Atan2(y, x) / Math.PI * 180;
double magnitude = Math.Sqrt(x * x + y * y);
if (angle < 0)
{
angle += 360;
}
// transform to indices in the Data array
var ii = (angle - this.Angle0) / (this.Angle1 - this.Angle0) * m;
var jj = (magnitude - this.Magnitude0) / (this.Magnitude1 - this.Magnitude0) * n;
if (ii >= 0 && ii < m && jj >= 0 && jj < n)
{
// get the (interpolated) value
var value = this.GetValue(ii, jj);
// use the color axis to get the color
p[xi, yi] = OxyColor.FromAColor(160, this.ColorAxis.GetColor(value));
}
else
{
// outside the range of the Data array
p[xi, yi] = OxyColors.Transparent;
}
}
}
// Create the PNG image
this.image = OxyImage.Create(p, ImageFormat.Png);
}
OxyRect dest;
if (this.PlotModel.PlotType != PlotType.Polar)
{
var topleft = this.Transform(-this.Magnitude1, this.Magnitude1);
var bottomright = this.Transform(this.Magnitude1, -this.Magnitude1);
dest = new OxyRect(topleft.X, topleft.Y, bottomright.X - topleft.X, bottomright.Y - topleft.Y);
}
else
{
var top = this.Transform(this.Magnitude1, 90);
var bottom = this.Transform(this.Magnitude1, 270);
var left = this.Transform(this.Magnitude1, 180);
var right = this.Transform(this.Magnitude1, 0);
dest = new OxyRect(left.X, top.Y, right.X - left.X, bottom.Y - top.Y);
}
// Render the image
var clip = this.GetClippingRect();
rc.DrawClippedImage(clip, this.image, dest.Left, dest.Top, dest.Width, dest.Height, 1, false);
}
示例4: 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);
}
}
示例5: RenderDynamic
/// <summary>
/// Renders by an image sized from the available plot area.
/// </summary>
/// <param name="rc">The rc.</param>
/// <param name="model">The model.</param>
public void RenderDynamic(IRenderContext rc, PlotModel model)
{
int m = this.Data.GetLength(0);
int n = this.Data.GetLength(1);
// get the available plot area
var dest = model.PlotArea;
int width = (int)dest.Width;
int height = (int)dest.Height;
if (width == 0 || height == 0)
{
return;
}
if (this.pixels == null || this.pixels.GetLength(0) != height || this.pixels.GetLength(1) != width)
{
this.pixels = new OxyColor[width, height];
}
var p = this.pixels;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
// transform from screen to magnitude/angle
var sp = new ScreenPoint(dest.Left + x, dest.Top + y);
var xy = this.InverseTransform(sp);
double angle;
double magnitude;
if (this.PlotModel.PlotType != PlotType.Polar)
{
angle = Math.Atan2(xy.Y, xy.X) / Math.PI * 180;
magnitude = Math.Sqrt((xy.X * xy.X) + (xy.Y * xy.Y));
}
else
{
angle = xy.Y / Math.PI * 180;
magnitude = xy.X;
if (angle < 0)
{
angle += 360;
}
}
// transform to indices in the Data array
var ii = (angle - this.Angle0) / (this.Angle1 - this.Angle0) * m;
var jj = (magnitude - this.Magnitude0) / (this.Magnitude1 - this.Magnitude0) * n;
if (ii >= 0 && ii < m && jj >= 0 && jj < n)
{
// get the (interpolated) value
var value = this.GetValue(ii, jj);
// use the color axis to get the color
p[x, y] = OxyColor.FromAColor(160, this.ColorAxis.GetColor(value));
}
else
{
// outside the range of the Data array
p[x, y] = OxyColors.Transparent;
}
}
}
// Create the PNG image
this.image = OxyImage.Create(p, ImageFormat.Png);
// Render the image
var clip = this.GetClippingRect();
rc.DrawClippedImage(clip, this.image, dest.Left, dest.Top, dest.Width, dest.Height, 1, false);
}
示例6: Render
/// <summary>
/// Renders the series on the specified render context.
/// </summary>
/// <param name="rc">The rendering context.</param>
/// <param name="model">The model.</param>
public override void Render(IRenderContext rc, PlotModel model)
{
if (this.Data == null)
{
this.image = null;
return;
}
double left = this.X0;
double right = this.X1;
double bottom = this.Y0;
double top = this.Y1;
int m = this.Data.GetLength(0);
int n = this.Data.GetLength(1);
double dx = (this.X1 - this.X0) / (m - 1);
double dy = (this.Y1 - this.Y0) / (n - 1);
if (this.CoordinateDefinition == HeatMapCoordinateDefinition.Center)
{
left -= dx / 2;
right += dx / 2;
bottom -= dy / 2;
top += dy / 2;
}
var s00 = this.Transform(left, bottom);
var s11 = this.Transform(right, top);
var rect = new OxyRect(s00, s11);
var currentDataHash = this.Data.GetHashCode();
var currentColorAxisHash = this.ColorAxis.GetElementHashCode();
if (this.image == null || currentDataHash != this.dataHash || currentColorAxisHash != this.colorAxisHash)
{
this.UpdateImage();
this.dataHash = currentDataHash;
this.colorAxisHash = currentColorAxisHash;
}
var clip = this.GetClippingRect();
if (this.image != null)
{
rc.DrawClippedImage(clip, this.image, rect.Left, rect.Top, rect.Width, rect.Height, 1, this.Interpolate);
}
if (this.LabelFontSize > 0)
{
this.RenderLabels(rc, rect);
}
}
示例7: Render
/// <summary>
/// Renders the series on the specified render context.
/// </summary>
/// <param name="rc">
/// The rendering context.
/// </param>
/// <param name="model">
/// The model.
/// </param>
public override void Render(IRenderContext rc, PlotModel model)
{
if (this.Data == null)
{
this.image = null;
return;
}
int m = this.Data.GetLength(0);
int n = this.Data.GetLength(1);
double dx = (this.X1 - this.X0) / m;
double left = this.X0 - (dx * 0.5);
double right = this.X1 + (dx * 0.5);
double dy = (this.Y1 - this.Y0) / n;
double bottom = this.Y0 - (dy * 0.5);
double top = this.Y1 + (dy * 0.5);
var s00 = this.Transform(left, bottom);
var s11 = this.Transform(right, top);
var rect = OxyRect.Create(s00, s11);
if (this.image == null || this.Data.GetHashCode() != this.dataHash)
{
this.UpdateImage();
this.dataHash = this.Data.GetHashCode();
}
if (this.image != null)
{
var clip = this.GetClippingRect();
rc.DrawClippedImage(clip, this.image, rect.Left, rect.Top, rect.Width, rect.Height, 1, true);
}
}
示例8: Render
/// <summary>
/// Renders the series on the specified render context.
/// </summary>
/// <param name="rc">The rendering context.</param>
/// <param name="model">The model.</param>
public override void Render(IRenderContext rc, PlotModel model)
{
if (this.Matrix == null)
{
return;
}
int m = this.Matrix.GetLength(0);
int n = this.Matrix.GetLength(1);
var p0 = this.Transform(0, 0);
var p1 = this.Transform(n, m);
// note matrix index [i,j] maps to image index [j,i]
if (this.image == null)
{
var pixels = new OxyColor[n, m];
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
pixels[j, i] = Math.Abs(this.Matrix[i, j]) <= this.ZeroTolerance ? OxyColors.Transparent : this.NotZeroColor;
}
}
this.image = OxyImage.Create(pixels, ImageFormat.Png);
}
var clip = this.GetClippingRect();
var x0 = Math.Min(p0.X, p1.X);
var y0 = Math.Min(p0.Y, p1.Y);
var w = Math.Abs(p0.X - p1.X);
var h = Math.Abs(p0.Y - p1.Y);
rc.DrawClippedImage(clip, this.image, x0, y0, w, h, 1, false);
var points = new List<ScreenPoint>();
if (this.GridInterval > 0)
{
var p2 = this.Transform(this.GridInterval, this.GridInterval);
if (Math.Abs(p2.Y - p0.Y) > this.MinimumGridLineDistance)
{
for (int i = 1; i < n; i += this.GridInterval)
{
points.Add(this.Transform(0, i));
points.Add(this.Transform(n, i));
}
}
if (Math.Abs(p2.X - p0.X) > this.MinimumGridLineDistance)
{
for (int j = 1; j < m; j += this.GridInterval)
{
points.Add(this.Transform(j, 0));
points.Add(this.Transform(j, m));
}
}
}
if (this.ShowDiagonal)
{
points.Add(this.Transform(0, 0));
points.Add(this.Transform(n, m));
}
rc.DrawClippedLineSegments(clip, points, this.GridColor, 1, null, LineJoin.Miter, true);
if (this.BorderColor.IsVisible())
{
var borderPoints = new[]
{
this.Transform(0, 0),
this.Transform(m, 0),
this.Transform(0, n),
this.Transform(m, n),
this.Transform(0, 0),
this.Transform(0, n),
this.Transform(m, 0),
this.Transform(m, n)
};
rc.DrawClippedLineSegments(clip, borderPoints, this.BorderColor, 1, null, LineJoin.Miter, true);
}
}
示例9: Render
/// <summary>
/// Renders the series on the specified render context.
/// </summary>
/// <param name="rc">The rendering context.</param>
public override void Render(IRenderContext rc)
{
if (this.Data == null)
{
this.image = null;
return;
}
if (this.ColorAxis == null)
{
throw new InvalidOperationException("Color axis not specified.");
}
double left = this.X0;
double right = this.X1;
double bottom = this.Y0;
double top = this.Y1;
int m = this.Data.GetLength(0);
int n = this.Data.GetLength(1);
double dx = (this.X1 - this.X0) / (m - 1);
double dy = (this.Y1 - this.Y0) / (n - 1);
if (this.CoordinateDefinition == HeatMapCoordinateDefinition.Center)
{
if (this.XAxis.IsLogarithmic())
{
double gx = Math.Log(this.X1 / this.X0) / (m - 1);
left *= Math.Exp(gx / -2);
right *= Math.Exp(gx / 2);
}
else
{
left -= dx / 2;
right += dx / 2;
}
if (this.YAxis.IsLogarithmic())
{
double gy = Math.Log(this.Y1 / this.Y0) / (n - 1);
bottom *= Math.Exp(gy / -2);
top *= Math.Exp(gy / 2);
}
else
{
bottom -= dy / 2;
top += dy / 2;
}
}
var s00 = this.Transform(left, bottom);
var s11 = this.Transform(right, top);
var rect = new OxyRect(s00, s11);
bool needImage = this.RenderMethod == HeatMapRenderMethod.Bitmap;
var currentDataHash = this.Data.GetHashCode();
var currentColorAxisHash = this.ColorAxis.GetElementHashCode();
if ((needImage && this.image == null) || currentDataHash != this.dataHash || currentColorAxisHash != this.colorAxisHash)
{
if (needImage)
{
this.UpdateImage();
}
this.dataHash = currentDataHash;
this.colorAxisHash = currentColorAxisHash;
}
var clip = this.GetClippingRect();
if (needImage)
{
if (this.image != null)
{
rc.DrawClippedImage(clip, this.image, rect.Left, rect.Top, rect.Width, rect.Height, 1, this.Interpolate);
}
}
else
{
s00 = this.Orientate(s00); // disorientate
s11 = this.Orientate(s11); // disorientate
double sdx = (s11.X - s00.X) / m;
double sdy = (s11.Y - s00.Y) / n;
// draw lots of rectangles
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
var rectcolor = this.ColorAxis.GetColor(this.Data[i, j]);
var pointa = this.Orientate(new ScreenPoint(s00.X + (i * sdx), s00.Y + (j * sdy))); // re-orientate
var pointb = this.Orientate(new ScreenPoint(s00.X + ((i + 1) * sdx), s00.Y + ((j + 1) * sdy))); // re-orientate
var rectrect = new OxyRect(pointa, pointb);
//.........这里部分代码省略.........