]> Creatis software - creaImageIO.git/blobdiff - src/creaImageIOUltrasonixImageReader.cpp
thread bug correction
[creaImageIO.git] / src / creaImageIOUltrasonixImageReader.cpp
index 8eb476bbb8605bbaea8eb3a75cc396a1e351a06b..2b9d783838ec869cb5b8eaaa1ee5749fe5b76dcd 100644 (file)
@@ -41,10 +41,10 @@ namespace creaImageIO
     fread(header, sizeof(int), HEADER_SIZE, Ultrasonix_file);
     if (ferror(Ultrasonix_file))
        return false;
-    h.type         = header[0];
-    h.frame        = header[1];
-    h.height       = header[2];
-    h.width        = header[3];
+    h.type         = header[1];
+    h.frame        = header[2];
+    h.height       = header[3];
+    h.width        = header[4];
     h.frequency    = header[14];
     h.samplingRate = header[15];
     //free(header);  
@@ -55,7 +55,7 @@ namespace creaImageIO
   //=====================================================================
   bool UltrasonixImageReader::CanRead(const std::string& filename)
   { 
-    long size;
+    long size = -1;
     bool ok = false;
     FILE *Ultrasonix_file=fopen(filename.c_str(), "rb");
     if (Ultrasonix_file) 
@@ -71,20 +71,25 @@ namespace creaImageIO
        fseek(Ultrasonix_file,0,SEEK_END);              // go to end of file
        if (h.type == TYPE_RF)
                size = (ftell(Ultrasonix_file) - (HEADER_SIZE+h.frame) * sizeof(int)) / sizeof(short);
-       else if (h.type == TYPE_B8)
-               size = (ftell(Ultrasonix_file) - HEADER_SIZE * sizeof(int)) / sizeof(char);
+       else if (h.type == 1)//TYPE_B8)
+               size = (ftell(Ultrasonix_file) - (HEADER_SIZE+h.frame+4) *  sizeof(int)) / sizeof(char);
        else if (h.type == TYPE_B32)
                size = (ftell(Ultrasonix_file) - HEADER_SIZE * sizeof(int)) / sizeof(int);
 
        // check if the data size corresponds to the dimensions of the images
-       if (size == h.width * h.height * h.frame)
+       if (size == h.width * h.height * h.frame )
                ok = true;
-               
+
        fclose(Ultrasonix_file);
     }
     return ok;
   }
   //=====================================================================
+  void UltrasonixImageReader::getAttributes(const std::string filename,
+               std::map <std::string , std::string> &infos, std::vector<std::string> i_attr)
+  {
+         //TO DO
+  }
   
   //=====================================================================
   vtkImageData* UltrasonixImageReader::ReadImage(const std::string& filename)