Mercurial > hg > orthanc
comparison OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp @ 4278:9279de56a405
avoid multiple calls to GetWidth() and GetHeight() on pixel loops
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 03 Nov 2020 20:05:55 +0100 |
parents | 0034f855c023 |
children | 3b70a2e6a06c |
comparison
equal
deleted
inserted
replaced
4277:c5ca798b158a | 4278:9279de56a405 |
---|---|
1361 | 1361 |
1362 unsigned int pitch = accessor.GetWidth() * bytesPerPixel; | 1362 unsigned int pitch = accessor.GetWidth() * bytesPerPixel; |
1363 Uint8* target = NULL; | 1363 Uint8* target = NULL; |
1364 pixels->createUint8Array(accessor.GetHeight() * pitch, target); | 1364 pixels->createUint8Array(accessor.GetHeight() * pitch, target); |
1365 | 1365 |
1366 for (unsigned int y = 0; y < accessor.GetHeight(); y++) | 1366 const unsigned int height = accessor.GetHeight(); |
1367 const unsigned int width = accessor.GetWidth(); | |
1368 | |
1369 for (unsigned int y = 0; y < height; y++) | |
1367 { | 1370 { |
1368 switch (accessor.GetFormat()) | 1371 switch (accessor.GetFormat()) |
1369 { | 1372 { |
1370 case PixelFormat_RGB24: | 1373 case PixelFormat_RGB24: |
1371 case PixelFormat_Grayscale8: | 1374 case PixelFormat_Grayscale8: |
1379 | 1382 |
1380 case PixelFormat_RGBA32: | 1383 case PixelFormat_RGBA32: |
1381 { | 1384 { |
1382 // The alpha channel is not supported by the DICOM standard | 1385 // The alpha channel is not supported by the DICOM standard |
1383 const Uint8* source = reinterpret_cast<const Uint8*>(accessor.GetConstRow(y)); | 1386 const Uint8* source = reinterpret_cast<const Uint8*>(accessor.GetConstRow(y)); |
1384 for (unsigned int x = 0; x < accessor.GetWidth(); x++, target += 3, source += 4) | 1387 for (unsigned int x = 0; x < width; x++, target += 3, source += 4) |
1385 { | 1388 { |
1386 target[0] = source[0]; | 1389 target[0] = source[0]; |
1387 target[1] = source[1]; | 1390 target[1] = source[1]; |
1388 target[2] = source[2]; | 1391 target[2] = source[2]; |
1389 } | 1392 } |