Mercurial > hg > orthanc
diff Core/Enumerations.cpp @ 800:ecedd89055db
generation of DICOM images from PNG files
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 06 May 2014 16:33:40 +0200 |
parents | dd1ce9a2844c |
children | a811bdf8b8eb |
line wrap: on
line diff
--- a/Core/Enumerations.cpp Tue May 06 12:55:41 2014 +0200 +++ b/Core/Enumerations.cpp Tue May 06 16:33:40 2014 +0200 @@ -247,6 +247,19 @@ } + const char* EnumerationToString(ImageFormat format) + { + switch (format) + { + case ImageFormat_Png: + return "Png"; + + default: + throw OrthancException(ErrorCode_ParameterOutOfRange); + } + } + + ResourceType StringToResourceType(const char* type) { std::string s(type); @@ -269,9 +282,44 @@ { return ResourceType_Instance; } - else + + throw OrthancException(ErrorCode_ParameterOutOfRange); + } + + + ImageFormat StringToImageFormat(const char* format) + { + std::string s(format); + Toolbox::ToUpperCase(s); + + if (s == "PNG") { - throw OrthancException(ErrorCode_ParameterOutOfRange); + return ImageFormat_Png; + } + + throw OrthancException(ErrorCode_ParameterOutOfRange); + } + + + unsigned int GetBytesPerPixel(PixelFormat format) + { + switch (format) + { + case PixelFormat_Grayscale8: + return 1; + + case PixelFormat_Grayscale16: + case PixelFormat_SignedGrayscale16: + return 2; + + case PixelFormat_RGB24: + return 3; + + case PixelFormat_RGBA32: + return 4; + + default: + throw OrthancException(ErrorCode_ParameterOutOfRange); } } }