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


C# System.Drawing.Bitmap.ToBitmapSource方法代码示例

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


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

示例1: ToBitmapSource

 /// <summary>
 /// Converts a <see cref="System.Drawing.Image"/> into a WPF <see cref="BitmapSource"/>.
 /// </summary>
 /// <param name="image">The image image.</param>
 /// <returns>A BitmapSource</returns>
 public static BitmapSource ToBitmapSource(this System.Drawing.Image image)
 {
     using (var bitmap = new System.Drawing.Bitmap(image))
     {
         return bitmap.ToBitmapSource();
     }
 }
开发者ID:mastersign,项目名称:minimods,代码行数:12,代码来源:Mastersign.Minimods.BitmapToBitmapSource.cs

示例2: sensor_AllFramesReady

        void sensor_AllFramesReady(object sender, AllFramesReadyEventArgs e)
        {
            using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
            {
                if (depthFrame == null)
                {
                    return;
                }

                int minDepth = 850;
                int maxDepth = 4000;

                System.Drawing.Bitmap outBmp = new System.Drawing.Bitmap(160, 160);
                BitmapSource depthBitmapSource;
                BitmapSource processedBitmapSource;

                //Get the position of interest on the depthmap from skeletal tracking
                DepthImagePoint rightHandPoint = jointTracker.GetJointPosition(kinectSensorChooser.Kinect, e, JointType.HandRight);

                if (jointTracker.JointDetected == true)
                {
                    textResult.Text = "Right hand is being tracked";

                    int rightHandDepth = rightHandPoint.Depth;
                    if (rightHandDepth < 850)
                    {
                        minDepth = 850;
                        maxDepth = 1500;
                    }
                    else
                    {
                        minDepth = rightHandDepth - 75;
                        maxDepth = rightHandDepth + 75;
                    }

                    depthBitmapSource = sliceDepthImage(depthFrame, minDepth, maxDepth);

                    //Create a bitmap from the depth information
                    System.Drawing.Bitmap depthBmp = depthBitmapSource.ToBitmap();

                    //Aforge performs image processing here.
                    outBmp = imageProcessor.ProcessFrame(depthBmp, rightHandPoint.X, rightHandPoint.Y);
                }
                else
                {
                    textResult.Text = "No hand detected";

                    //depthBitmapSource = sliceDepthImage(depthFrame, 850, 1500);

                    System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(outBmp);
                    g.Clear(System.Drawing.Color.Black);
                }

                //Create a bitmapsource to show the processed image
                processedBitmapSource = outBmp.ToBitmapSource();

                //Display the images
                procImageDisplay.Source = processedBitmapSource;
            }
        }
开发者ID:pvishal,项目名称:kinect-hands,代码行数:60,代码来源:MainWindow.xaml.cs

示例3: sensor_AllFramesReady

        void sensor_AllFramesReady(object sender, AllFramesReadyEventArgs e)
        {
            using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
            {
                if (depthFrame == null)
                {
                    return;
                }

                if (sliderMinDist.Value > sliderMaxDist.Value)
                {
                    sliderMinDist.Value = sliderMaxDist.Value;
                }

                textMinDistVal.Text = sliderMinDist.Value.ToString();
                textMaxDistVal.Text = sliderMaxDist.Value.ToString();

                BitmapSource depthBitmapSource = sliceDepthImage(depthFrame, (int)sliderMinDist.Value, (int)sliderMaxDist.Value);

                //Create a bitmap from the depth information
                System.Drawing.Bitmap depthBmp = depthBitmapSource.ToBitmap();
                System.Drawing.Bitmap outBmp = new System.Drawing.Bitmap(depthBmp.Width, depthBmp.Height);

                //Aforge performs image processing here.
                outBmp = blobsDetector.ProcessFrame(depthBmp, trackMode);

                textResult.Text = blobsDetector.TotalBlobCount + " blobs detected.";

                //Create a bitmapsource to show the processed image
                BitmapSource procBitmapSource = outBmp.ToBitmapSource();

                //Display the images
                depthImageDisplay.Source = depthBitmapSource;
                procImageDisplay.Source = procBitmapSource;
            }
        }
开发者ID:pvishal,项目名称:kinpos,代码行数:36,代码来源:MainWindow.xaml.cs


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