本文整理汇总了C#中Pixel.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# Pixel.GetLength方法的具体用法?C# Pixel.GetLength怎么用?C# Pixel.GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pixel
的用法示例。
在下文中一共展示了Pixel.GetLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RawImage
public RawImage( int zoom, Rectangle bounds, Pixel[,] memory )
{
this.zoom = zoom;
this.bounds = bounds;
if ( memory.GetLength(0) != bounds.Width || memory.GetLength(1) != bounds.Height ) throw new ArgumentOutOfRangeException( "memory" );
this.memory = memory;
}
示例2: ToPixelMatriz
public static Pixel[,] ToPixelMatriz(this Color[,] colorMatriu)
{
Pixel[,] matriu = new Pixel[colorMatriu.GetLength(DimensionMatriz.X), colorMatriu.GetLength(DimensionMatriz.X)];
for (int y = 0; y < matriu.GetLength(DimensionMatriz.Y); y++)
for (int x = 0; x < matriu.GetLength(DimensionMatriz.X); x++)
if (colorMatriu[x, y] != Color.Transparent)
matriu[x, y] = new Pixel(colorMatriu[x, y], new PointZ(x, y, 0));
return matriu;
}
示例3: MinDistanceRegion
public Rectangle MinDistanceRegion(Rectangle sourceRect, ImgGradient gradient, Pixel[,] layerPixels, SelectionMask selectionMask)
{
Debug.Assert(sourceRect.Width == sourceRect.Height);
var windowSize = sourceRect.Width;
var windowDelta = windowSize/2;
var layerWidth = layerPixels.GetLength(0);
var layerHeight = layerPixels.GetLength(1);
Rectangle minRegionRect = null;
var minDistance = 0.0;
var adjustedSourceRect = sourceRect.AdjustedToImageEdges(new Rectangle(new IntCoordinate(0, 0),
layerWidth, layerHeight));
var currentCoordinate = new IntCoordinate(0, 0);
var orthoGradient = new Coordinate<double>(-gradient.YMagnitude*windowDelta,
gradient.XMagnitude*windowDelta);
for (int i = windowDelta; i < layerWidth - windowDelta; i++)
{
for (int j = windowDelta; j < layerHeight - windowDelta; j++)
{
if (j == sourceRect.Y1 + windowDelta && i == sourceRect.X1 + windowDelta)
{
continue;
}
currentCoordinate.X = i;
currentCoordinate.Y = j;
var currentRgnRect = currentCoordinate.PointCenteredRectangle(windowSize);
var dist = RegionDistance(adjustedSourceRect, currentRgnRect, layerPixels, selectionMask);
if (dist == null)
{
continue;
}
if (dist == 0)
{
return currentRgnRect;
}
if ((minDistance > dist || minRegionRect == null))
{
minDistance = (double) dist;
minRegionRect = currentRgnRect;
}
}
}
return minRegionRect;
}
示例4: RegionDistance
public double? RegionDistance(Pixel[,] source, Rectangle rgnRect, Drawable drawable, SelectionMask selectionMask)
{
var sum = 0.0;
var sourceWidth = source.GetLength(0);
var sourceHeight = source.GetLength(1);
var rgn = new PixelRgn(drawable, rgnRect, false, false);
for (IntPtr pr = PixelRgn.Register(rgn);
pr != IntPtr.Zero;
pr = PixelRgn.Process(pr))
{
for (int y1 = rgn.Y - rgnRect.UpperLeft.Y, y2 = rgn.Y;
y2 < rgn.Y + rgn.H;
y1++, y2++)
{
for (int x1 = rgn.X - rgnRect.UpperLeft.X, x2 = rgn.X;
x2 < rgn.X + rgn.W;
x1++, x2++)
{
if (selectionMask[x2, y2])
{
return null;
}
if (x1 >= sourceWidth ||
x2 >= sourceHeight ||
source[x1, y1] == null)
{
continue;
}
sum += DistanceSqr(source[x1, y1], rgn[y2, x2]);
}
}
}
return sum;
}