comparison OrthancServer/FromDcmtkBridge.cpp @ 369:4632a044746e

simplification of the code
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 19 Feb 2013 12:09:03 +0100
parents 80011cd589e6
children 4d5f0857ec9c
comparison
equal deleted inserted replaced
368:80011cd589e6 369:4632a044746e
1240 accessor.reset(new DicomIntegerPixelAccessor(m, pixData, privateContent.size())); 1240 accessor.reset(new DicomIntegerPixelAccessor(m, pixData, privateContent.size()));
1241 accessor->SetCurrentFrame(frame); 1241 accessor->SetCurrentFrame(frame);
1242 } 1242 }
1243 1243
1244 PixelFormat format; 1244 PixelFormat format;
1245 1245 bool supported = false;
1246 if (accessor->GetChannelCount() != 1 && 1246
1247 (mode == ImageExtractionMode_UInt8 || 1247 if (accessor->GetChannelCount() == 1)
1248 mode == ImageExtractionMode_UInt16)) 1248 {
1249 switch (mode)
1250 {
1251 case ImageExtractionMode_Preview:
1252 supported = true;
1253 format = PixelFormat_Grayscale8;
1254 break;
1255
1256 case ImageExtractionMode_UInt8:
1257 supported = true;
1258 format = PixelFormat_Grayscale8;
1259 break;
1260
1261 case ImageExtractionMode_UInt16:
1262 supported = true;
1263 format = PixelFormat_Grayscale16;
1264 break;
1265
1266 default:
1267 supported = false;
1268 break;
1269 }
1270 }
1271 else if (accessor->GetChannelCount() == 3)
1272 {
1273 switch (mode)
1274 {
1275 case ImageExtractionMode_Preview:
1276 supported = true;
1277 format = PixelFormat_RGB24;
1278 break;
1279
1280 default:
1281 supported = false;
1282 break;
1283 }
1284 }
1285
1286 if (!supported)
1249 { 1287 {
1250 throw OrthancException(ErrorCode_NotImplemented); 1288 throw OrthancException(ErrorCode_NotImplemented);
1251 } 1289 }
1252
1253 switch (mode)
1254 {
1255 case ImageExtractionMode_Preview:
1256 switch (accessor->GetChannelCount())
1257 {
1258 case 1:
1259 format = PixelFormat_Grayscale8;
1260 break;
1261
1262 case 3:
1263 format = PixelFormat_RGB24;
1264 break;
1265
1266 default:
1267 throw OrthancException(ErrorCode_NotImplemented);
1268 }
1269 break;
1270
1271 case ImageExtractionMode_UInt8:
1272 format = PixelFormat_Grayscale8;
1273 break;
1274
1275 case ImageExtractionMode_UInt16:
1276 format = PixelFormat_Grayscale16;
1277 break;
1278
1279 default:
1280 throw OrthancException(ErrorCode_NotImplemented);
1281 }
1282 1290
1283 if (accessor.get() == NULL || 1291 if (accessor.get() == NULL ||
1284 accessor->GetWidth() == 0 || 1292 accessor->GetWidth() == 0 ||
1285 accessor->GetHeight() == 0) 1293 accessor->GetHeight() == 0)
1286 { 1294 {