From 93823ad6bb2299f510fc9cc4774838267259d5f8 Mon Sep 17 00:00:00 2001
From: Patrick Imbo <patrick.imbo@c-s.fr>
Date: Wed, 1 Dec 2010 16:16:57 +0100
Subject: [PATCH] BUG: improve the GetDefaultDisplay() mehtod -> now process
 any number of bands

---
 Code/IO/otbDefaultImageMetadataInterface.h | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/Code/IO/otbDefaultImageMetadataInterface.h b/Code/IO/otbDefaultImageMetadataInterface.h
index 0f9841a1f7..2aac5da01d 100644
--- a/Code/IO/otbDefaultImageMetadataInterface.h
+++ b/Code/IO/otbDefaultImageMetadataInterface.h
@@ -151,13 +151,23 @@ public:
   }
 
   /** Get the 3 spectral band numbers corresponding to the default display for visualization,
-   *  in the order R, G, B */
+   *  in the order R, G, B.
+   *
+   *  Nota : When two spectral bands are available: first band is given to the R and B channel
+   *         When one spectral band is available : the only band is given to the R, G and B channel.
+   *
+   */
   std::vector<unsigned int> GetDefaultDisplay() const
   {
+    unsigned int i = 0;
     std::vector<unsigned int> rgb(3);
-    rgb[0] = 0;
-    rgb[1] = 1;
-    rgb[2] = 2;
+
+
+    while( i <this->GetNumberOfBands() || i < 3 )
+      {
+      rgb[i] = i;
+      ++i;
+      }
     return rgb;
   }
 
-- 
GitLab