comparison 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
comparison
equal deleted inserted replaced
799:777b6b694da6 800:ecedd89055db
245 throw OrthancException(ErrorCode_ParameterOutOfRange); 245 throw OrthancException(ErrorCode_ParameterOutOfRange);
246 } 246 }
247 } 247 }
248 248
249 249
250 const char* EnumerationToString(ImageFormat format)
251 {
252 switch (format)
253 {
254 case ImageFormat_Png:
255 return "Png";
256
257 default:
258 throw OrthancException(ErrorCode_ParameterOutOfRange);
259 }
260 }
261
262
250 ResourceType StringToResourceType(const char* type) 263 ResourceType StringToResourceType(const char* type)
251 { 264 {
252 std::string s(type); 265 std::string s(type);
253 Toolbox::ToUpperCase(s); 266 Toolbox::ToUpperCase(s);
254 267
267 else if (s == "INSTANCE" || s == "IMAGE" || 280 else if (s == "INSTANCE" || s == "IMAGE" ||
268 s == "INSTANCES" || s == "IMAGES") 281 s == "INSTANCES" || s == "IMAGES")
269 { 282 {
270 return ResourceType_Instance; 283 return ResourceType_Instance;
271 } 284 }
272 else 285
273 { 286 throw OrthancException(ErrorCode_ParameterOutOfRange);
274 throw OrthancException(ErrorCode_ParameterOutOfRange); 287 }
288
289
290 ImageFormat StringToImageFormat(const char* format)
291 {
292 std::string s(format);
293 Toolbox::ToUpperCase(s);
294
295 if (s == "PNG")
296 {
297 return ImageFormat_Png;
298 }
299
300 throw OrthancException(ErrorCode_ParameterOutOfRange);
301 }
302
303
304 unsigned int GetBytesPerPixel(PixelFormat format)
305 {
306 switch (format)
307 {
308 case PixelFormat_Grayscale8:
309 return 1;
310
311 case PixelFormat_Grayscale16:
312 case PixelFormat_SignedGrayscale16:
313 return 2;
314
315 case PixelFormat_RGB24:
316 return 3;
317
318 case PixelFormat_RGBA32:
319 return 4;
320
321 default:
322 throw OrthancException(ErrorCode_ParameterOutOfRange);
275 } 323 }
276 } 324 }
277 } 325 }