本文整理汇总了C#中System.Windows.Media.ScaleTransform.Transform方法的典型用法代码示例。如果您正苦于以下问题:C# ScaleTransform.Transform方法的具体用法?C# ScaleTransform.Transform怎么用?C# ScaleTransform.Transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.ScaleTransform
的用法示例。
在下文中一共展示了ScaleTransform.Transform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCrossSectionProfile
public void GetCrossSectionProfile(List<Point> list, string fileName, int TotalPoints, double fPointWidth)
{
BitmapImage myBitmapImage = GetImage(fileName);
if (myBitmapImage == null)
{
return;
}
FormatConvertedBitmap newFormatedBitmapSource = new FormatConvertedBitmap();
newFormatedBitmapSource.BeginInit();
newFormatedBitmapSource.Source = myBitmapImage;
newFormatedBitmapSource.DestinationFormat = PixelFormats.Rgb24;
newFormatedBitmapSource.EndInit();
int width = newFormatedBitmapSource.PixelWidth;
int stride = width * 3;
int size = newFormatedBitmapSource.PixelHeight * stride;
byte[] pixels = new byte[size];
Array.Clear(pixels, 0, size);
newFormatedBitmapSource.CopyPixels(pixels, stride, 0);
int x = 0;
int y = 0;
Point ptCenter = new Point();
ptCenter.X = newFormatedBitmapSource.PixelWidth / 2;
ptCenter.Y = newFormatedBitmapSource.PixelHeight / 2;
int r_begin_min = (int)Math.Min(ptCenter.X, ptCenter.Y);
ScaleTransform scaleTransform = new ScaleTransform(fPointWidth, fPointWidth);
double delta = TotalPoints / 360;
for (double angle = 0; angle < 360; angle += delta)
{
double rad_angle = Math.PI * angle / 180.0;
int r_begin = (int)Math.Sqrt(2 * r_begin_min * r_begin_min);
for (double r = r_begin; r > 0; r-=1)
{
x = (int)(r * Math.Cos(rad_angle)) + (int)ptCenter.X;
y = (int)(r * Math.Sin(rad_angle)) + (int)ptCenter.Y;
if (x >= newFormatedBitmapSource.PixelWidth ||
y >= newFormatedBitmapSource.PixelHeight ||
x < 0 || y < 0)
{
continue;
}
int index = y * stride + 3 * x;
byte red = pixels[index];
byte green = pixels[index + 1];
byte blue = pixels[index + 2];
Color cur_col = Color.FromRgb(red, green, blue);
if (cur_col != Color.FromRgb(255, 255, 255))
{
int x_add = x - (int)ptCenter.X;
int y_add = y - (int)ptCenter.Y;
Point ptToAdd = new Point(x_add, y_add);
if (list.Count == 0 || list.Last() != ptToAdd)
{
list.Add(ptToAdd);
if (list.Count == 215)
{
int h = 0 + 4;
}
}
break;
}
}
}
if (scaleTransform != null)
{
for (int i = 0; i < list.Count; i++)
{
list[i] = scaleTransform.Transform(list[i]);
}
}
}