當前位置: 首頁>>代碼示例>>C#>>正文


C# ScaleTransform.Transform方法代碼示例

本文整理匯總了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]);
                }

            }
        }
開發者ID:pruginkad,項目名稱:webinterest,代碼行數:82,代碼來源:MainWindow.xaml.cs


注:本文中的System.Windows.Media.ScaleTransform.Transform方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。