Mercurial > hg > orthanc
comparison Core/Enumerations.cpp @ 948:e57e08ed510f dicom-rt
integration mainline -> dicom-rt
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 25 Jun 2014 13:57:05 +0200 |
parents | a811bdf8b8eb |
children | e56c3ed8d738 |
comparison
equal
deleted
inserted
replaced
767:c19552f604d5 | 948:e57e08ed510f |
---|---|
28 * You should have received a copy of the GNU General Public License | 28 * You should have received a copy of the GNU General Public License |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 29 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
30 **/ | 30 **/ |
31 | 31 |
32 | 32 |
33 #include "PrecompiledHeaders.h" | |
33 #include "Enumerations.h" | 34 #include "Enumerations.h" |
34 | 35 |
35 #include "OrthancException.h" | 36 #include "OrthancException.h" |
36 #include "Toolbox.h" | 37 #include "Toolbox.h" |
37 | 38 |
245 throw OrthancException(ErrorCode_ParameterOutOfRange); | 246 throw OrthancException(ErrorCode_ParameterOutOfRange); |
246 } | 247 } |
247 } | 248 } |
248 | 249 |
249 | 250 |
251 const char* EnumerationToString(ImageFormat format) | |
252 { | |
253 switch (format) | |
254 { | |
255 case ImageFormat_Png: | |
256 return "Png"; | |
257 | |
258 default: | |
259 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
260 } | |
261 } | |
262 | |
263 | |
250 ResourceType StringToResourceType(const char* type) | 264 ResourceType StringToResourceType(const char* type) |
251 { | 265 { |
252 std::string s(type); | 266 std::string s(type); |
253 Toolbox::ToUpperCase(s); | 267 Toolbox::ToUpperCase(s); |
254 | 268 |
267 else if (s == "INSTANCE" || s == "IMAGE" || | 281 else if (s == "INSTANCE" || s == "IMAGE" || |
268 s == "INSTANCES" || s == "IMAGES") | 282 s == "INSTANCES" || s == "IMAGES") |
269 { | 283 { |
270 return ResourceType_Instance; | 284 return ResourceType_Instance; |
271 } | 285 } |
272 else | 286 |
273 { | 287 throw OrthancException(ErrorCode_ParameterOutOfRange); |
274 throw OrthancException(ErrorCode_ParameterOutOfRange); | 288 } |
289 | |
290 | |
291 ImageFormat StringToImageFormat(const char* format) | |
292 { | |
293 std::string s(format); | |
294 Toolbox::ToUpperCase(s); | |
295 | |
296 if (s == "PNG") | |
297 { | |
298 return ImageFormat_Png; | |
299 } | |
300 | |
301 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
302 } | |
303 | |
304 | |
305 unsigned int GetBytesPerPixel(PixelFormat format) | |
306 { | |
307 switch (format) | |
308 { | |
309 case PixelFormat_Grayscale8: | |
310 return 1; | |
311 | |
312 case PixelFormat_Grayscale16: | |
313 case PixelFormat_SignedGrayscale16: | |
314 return 2; | |
315 | |
316 case PixelFormat_RGB24: | |
317 return 3; | |
318 | |
319 case PixelFormat_RGBA32: | |
320 return 4; | |
321 | |
322 default: | |
323 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
275 } | 324 } |
276 } | 325 } |
277 } | 326 } |