MID:
authorbastiena
Mon, 30 Jul 2012 16:45:46 +0200
changeset 57 d0c393730443
parent 56 7d0ae2f385e7
child 58 a28488078053
MID: bug load bmp fixed
middleware/Debug/DebugWindow.xaml.cs
--- a/middleware/Debug/DebugWindow.xaml.cs	Thu Jul 26 17:44:35 2012 +0200
+++ b/middleware/Debug/DebugWindow.xaml.cs	Mon Jul 30 16:45:46 2012 +0200
@@ -39,7 +39,7 @@
     public partial class DebugWindow : Window
     {
         //Nom du projet, afin de savoir quel menu charger et quel fichier de configuration utiliser (TraKERS ou BBM).
-        private String projectName = "BBM";
+        private String projectName = "TraKERS";
         //Chemins du fichier de config.
         private String configPath;
         //private String projectName = "BBM";
@@ -66,6 +66,9 @@
         //Indique si l'image doit être raffraichie.
         private Boolean refreshImage;
 
+        //Images des mains.
+        BitmapSource right_hand_onBitmap, right_hand_offBitmap, left_hand_onBitmap, left_hand_offBitmap;
+
         /*
         * Constructeur : Affiche la fenêtre de debug en lui passant en paramètre une instanciation de la
         * classe KinectMain.
@@ -97,9 +100,13 @@
             }
 
             //On initialise les images des mains.
-            Bitmap rightHandBitmap = getImage(imgLocation + "\\right_hand_off.png"), leftHandBitmap = getImage(imgLocation + "\\left_hand_off.png");
-            LeftHand.Source = CreateBitmapSourceFromBitmap(leftHandBitmap);
-            RightHand.Source = CreateBitmapSourceFromBitmap(rightHandBitmap);
+            right_hand_onBitmap = CreateBitmapSourceFromBitmap(getImage(imgLocation + "\\right_hand_on.png"));
+            right_hand_offBitmap = CreateBitmapSourceFromBitmap(getImage(imgLocation + "\\right_hand_off.png"));
+            left_hand_onBitmap = CreateBitmapSourceFromBitmap(getImage(imgLocation + "\\left_hand_on.png"));
+            left_hand_offBitmap = CreateBitmapSourceFromBitmap(getImage(imgLocation + "\\left_hand_off.png"));
+
+            LeftHand.Source = left_hand_offBitmap;
+            RightHand.Source = right_hand_offBitmap;
             //On initialise les images de proximité.
             Bitmap userBitmap = getImage(imgLocation + "\\user.png"), kinectBitmap = getImage(imgLocation + "\\kinect.png");
             UserImage.Source = CreateBitmapSourceFromBitmap(userBitmap);
@@ -427,14 +434,14 @@
         */
         public void showRightHandRect(bool show)
         {
-            Bitmap bitmap = null;
+            BitmapSource source = null;
 
             if (show)
-                bitmap = getImage(imgLocation + "\\right_hand_on.png");
+                source = right_hand_onBitmap;
             else
-                bitmap = getImage(imgLocation + "\\right_hand_off.png");
+                source = right_hand_offBitmap;
 
-            RightHand.Source = CreateBitmapSourceFromBitmap(bitmap);
+            RightHand.Source = source;
         }
 
         /*
@@ -442,14 +449,14 @@
         */
         public void showLeftHandRect(bool show)
         {
-            Bitmap bitmap = null;
+            BitmapSource source = null;
 
             if (show)
-                bitmap = getImage(imgLocation + "\\left_hand_on.png");
+                source = left_hand_onBitmap;
             else
-                bitmap = getImage(imgLocation + "\\left_hand_off.png");
+                source = left_hand_offBitmap;
 
-            LeftHand.Source = CreateBitmapSourceFromBitmap(bitmap);
+            LeftHand.Source = source;
         }
 
         /*
@@ -664,11 +671,18 @@
             if (bitmap == null)
                 return null;
 
-            return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
+            try
+            {
+                return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                 bitmap.GetHbitmap(),
                 IntPtr.Zero,
                 Int32Rect.Empty,
                 BitmapSizeOptions.FromEmptyOptions());
+            }
+            catch (Exception)
+            {
+                return null;
+            }
         }
 
         /*