Help!!! What does this program do?
-
Hi, can anyone explain what does the program below do in MFC C++. void CMediVisionView::OnFileSaveasraw() { // TODO: Add your command handler code here// FILE *raw; int n; unsigned short sdata; static char BASED_CODE szFilter[] = "DICOM Files (*.txt)|*.txt|All Files(*.*)|*.*||"; CFileDialog dlg_save_as(FALSE, "dcm", NULL, OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, szFilter); if(dlg_save_as.DoModal() == IDOK) { raw = fopen("test.raw","a+b"); for (n=0; n
-
Hi, can anyone explain what does the program below do in MFC C++. void CMediVisionView::OnFileSaveasraw() { // TODO: Add your command handler code here// FILE *raw; int n; unsigned short sdata; static char BASED_CODE szFilter[] = "DICOM Files (*.txt)|*.txt|All Files(*.*)|*.*||"; CFileDialog dlg_save_as(FALSE, "dcm", NULL, OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, szFilter); if(dlg_save_as.DoModal() == IDOK) { raw = fopen("test.raw","a+b"); for (n=0; n
It shows that the person who wrote it doesn't know C++, but knows C. It's very poorly written code to open a file dialog, and open a DICOM file which has been saved as a .txt file ( this is ridiculous ), and then it opens the file, and it scales every value by taking a new theoretical maximum value, and it assumes the old maximum was 256. According to this, a RAW file is not 10 bit at all, it's just 8 bit, one byte per pixel. Christian Graus - Microsoft MVP - C++
-
It shows that the person who wrote it doesn't know C++, but knows C. It's very poorly written code to open a file dialog, and open a DICOM file which has been saved as a .txt file ( this is ridiculous ), and then it opens the file, and it scales every value by taking a new theoretical maximum value, and it assumes the old maximum was 256. According to this, a RAW file is not 10 bit at all, it's just 8 bit, one byte per pixel. Christian Graus - Microsoft MVP - C++
Can you advice on a better way to write this program?thks.
-
Can you advice on a better way to write this program?thks.
1. Don't put all variable declarations at the top of the function. C requires it, C++ does not, and it's ugly 2. ALWAYS give any variable you create a default value, when you create it. 3. Don't use crappy C FILE handles, use iostreams 4. Don't use a file extension with a known value and use it to store something totally different. 5. Don't integrate code into your code base if you have no idea what it does. Christian Graus - Microsoft MVP - C++