Salome HOME
Refs #279 - Copy for the view position coordinates
[modules/hydro.git] / src / HYDROData / HYDROData_Image.cxx
index c8fb2713479a1eeed0573a1590d1ebd514f24454..0d1d5bcb07dfcd3c8dc070e856bc69071fdd90bb 100644 (file)
@@ -201,6 +201,8 @@ void HYDROData_Image::Update()
   {
     UpdateTrsf();
   }
+
+  SetToUpdate( false );
 }
 
 QVariant HYDROData_Image::GetDataVariant()
@@ -240,18 +242,27 @@ void HYDROData_Image::SetImage(const QImage& theImage)
   }
   else
   {
+    QImage anImage;
+
+    // convert 8-bits images
+    if ( theImage.format() == QImage::Format_Indexed8 ) {
+      anImage = theImage.convertToFormat( QImage::Format_RGB32 );
+    } else {
+      anImage = theImage;
+    }
+
     // store width, height, bytes per line and format in integer array 
     Handle(TDataStd_IntegerArray) aParams;
     if (!myLab.FindAttribute(TDataStd_IntegerArray::GetID(), aParams)) {
       aParams = TDataStd_IntegerArray::Set(myLab, 1, 4);
     }
-    aParams->SetValue(1, theImage.width());
-    aParams->SetValue(2, theImage.height());
-    aParams->SetValue(3, theImage.bytesPerLine());
-    aParams->SetValue(4, (int)(theImage.format()));
+    aParams->SetValue(1, anImage.width());
+    aParams->SetValue(2, anImage.height());
+    aParams->SetValue(3, anImage.bytesPerLine());
+    aParams->SetValue(4, (int)(anImage.format()));
     // store data of image in byte array
-    const char* aData = (const char*)(theImage.bits());
-    SaveByteArray(0, aData, theImage.byteCount());
+    const char* aData = (const char*)(anImage.bits());
+    SaveByteArray(0, aData, anImage.byteCount());
   }
 
   SetToUpdate( true );