Forráskód Böngészése

设置用户身体框架透明显示

王育民 5 éve
szülő
commit
0c66b11406
2 módosított fájl, 17 hozzáadás és 9 törlés
  1. 1 0
      FireDrill/FireDrill.csproj
  2. 16 9
      FireDrill/MainWindow.xaml.cs

+ 1 - 0
FireDrill/FireDrill.csproj

@@ -39,6 +39,7 @@
     <Reference Include="Microsoft.Kinect, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
     <Reference Include="System" />
     <Reference Include="System.Data" />
+    <Reference Include="System.Drawing" />
     <Reference Include="System.Windows.Forms" />
     <Reference Include="System.Xml" />
     <Reference Include="Microsoft.CSharp" />

+ 16 - 9
FireDrill/MainWindow.xaml.cs

@@ -34,13 +34,19 @@ namespace FireDrill
         // 用于显示 BodyIndexFrame 数据的颜色集合
         private static readonly uint[] BodyColor =
         {
-            0x0000FF00,
-            0x00FF0000,
-            0xFFFF4000,
-            0x40FFFF00,
-            0xFF40FF00,
-            0xFF808000,
-        };
+            //0x0000FF00,
+            //0x00FF0000,
+            //0xFFFF4000,
+            //0x40FFFF00,
+            //0xFF40FF00,
+            //0xFF808000,
+            (uint)System.Drawing.Color.White.ToArgb(),
+            (uint)System.Drawing.Color.White.ToArgb(),
+            (uint)System.Drawing.Color.White.ToArgb(),
+            (uint)System.Drawing.Color.White.ToArgb(),
+            (uint)System.Drawing.Color.White.ToArgb(),
+            (uint)System.Drawing.Color.White.ToArgb(),
+    };
 
         // 坐标映射器将一种类型的点映射到另一种
         private CoordinateMapper _coordinateMapper = null;
@@ -133,7 +139,7 @@ namespace FireDrill
             // allocate space to put the pixels being converted
             bodyIndexPixels = new uint[bodyIndexFrameDescription.Width * bodyIndexFrameDescription.Height];
             // create the bitmap to display
-            bodyIndexBitmap = new WriteableBitmap(bodyIndexFrameDescription.Width, bodyIndexFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null);
+            bodyIndexBitmap = new WriteableBitmap(bodyIndexFrameDescription.Width, bodyIndexFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgra32, null);
             // 设置 IsAvailableChanged 事件通知程序
             _kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;
             // 打开传感器
@@ -283,7 +289,8 @@ namespace FireDrill
                 else
                 {
                     // 此像素不是播放器的一部分,显示黑色
-                    bodyIndexPixels[i] = 0x00000000;
+                    //bodyIndexPixels[i] = 0x0000000F;
+                    bodyIndexPixels[i] = (uint)System.Drawing.Color.Transparent.ToArgb();
                 }
             }
         }