read magic number from file return true if this is your image type, false if it is not
| 148 | // return true if this is your image type, false if it is not |
| 149 | // |
| 150 | bool DICOMParser::IsDICOMFile(DICOMFile* file) |
| 151 | { |
| 152 | char magic_number[4]; |
| 153 | file->SkipToStart(); |
| 154 | file->Read(static_cast<void*>(magic_number), 4); |
| 155 | if (CheckMagic(magic_number)) |
| 156 | { |
| 157 | return (true); |
| 158 | } |
| 159 | // try with optional skip |
| 160 | else |
| 161 | { |
| 162 | file->Skip(OPTIONAL_SKIP - 4); |
| 163 | file->Read(static_cast<void*>(magic_number), 4); |
| 164 | if (CheckMagic(magic_number)) |
| 165 | { |
| 166 | return true; |
| 167 | } |
| 168 | else |
| 169 | { |
| 170 | |
| 171 | #ifndef DICOMPARSER_IGNORE_MAGIC_NUMBER |
| 172 | return false; |
| 173 | #else |
| 174 | // |
| 175 | // Try it anyways... |
| 176 | // |
| 177 | |
| 178 | file->SkipToStart(); |
| 179 | |
| 180 | doublebyte group = file->ReadDoubleByte(); |
| 181 | bool dicom; |
| 182 | if (group == 0x0002 || group == 0x0008) |
| 183 | { |
| 184 | std::cerr << "No DICOM magic number found, but file appears to be DICOM." << std::endl; |
| 185 | std::cerr << "Proceeding without caution." << std::endl; |
| 186 | dicom = true; |
| 187 | } |
| 188 | else |
| 189 | { |
| 190 | dicom = false; |
| 191 | } |
| 192 | file->SkipToStart(); |
| 193 | |
| 194 | return dicom; |
| 195 | #endif // DICOMPARSER_IGNORE_MAGIC_NUMBER |
| 196 | } |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | bool DICOMParser::IsValidRepresentation(doublebyte rep, quadbyte& len, VRTypes& mytype) |
| 201 | { |
no test coverage detected