Mercurial > hg > orthanc-stone
comparison Framework/Loaders/OrthancMultiframeVolumeLoader.cpp @ 1362:104e0b0f2316 broker
Fixed the broken function, and left the unoptimized
code with an #if for review.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 15 Apr 2020 17:48:38 +0200 |
parents | b1e6bef86955 |
children | f4a06ad1580b |
comparison
equal
deleted
inserted
replaced
1361:bd26e09903c0 | 1362:104e0b0f2316 |
---|---|
310 { | 310 { |
311 OrthancStone::ImageBuffer3D::SliceWriter writer(target, OrthancStone::VolumeProjection_Axial, z); | 311 OrthancStone::ImageBuffer3D::SliceWriter writer(target, OrthancStone::VolumeProjection_Axial, z); |
312 | 312 |
313 assert(writer.GetAccessor().GetWidth() == width && | 313 assert(writer.GetAccessor().GetWidth() == width && |
314 writer.GetAccessor().GetHeight() == height); | 314 writer.GetAccessor().GetHeight() == height); |
315 | 315 #if 0 |
316 T* targetAddr0 = reinterpret_cast<T*>(writer.GetAccessor().GetRow(0)); | |
317 unsigned int pitch = writer.GetAccessor().GetPitch(); | |
318 T* targetAddr = targetAddr0; | |
319 assert(sizeof(T) == Orthanc::GetBytesPerPixel(target.GetFormat())); | |
320 | |
321 for (unsigned int y = 0; y < height; y++) | 316 for (unsigned int y = 0; y < height; y++) |
322 { | 317 { |
318 assert(sizeof(T) == Orthanc::GetBytesPerPixel(target.GetFormat())); | |
319 | |
320 T* target = reinterpret_cast<T*>(writer.GetAccessor().GetRow(y)); | |
321 | |
323 for (unsigned int x = 0; x < width; x++) | 322 for (unsigned int x = 0; x < width; x++) |
324 { | 323 { |
325 CopyPixel(*targetAddr, source); | 324 CopyPixel(*target, source); |
326 | 325 |
327 distribution[*targetAddr] += 1; | 326 distribution[*target] += 1; |
328 | 327 |
329 targetAddr++; | 328 target++; |
330 source += bpp; | 329 source += bpp; |
331 } | 330 } |
332 targetAddr += pitch; | |
333 } | 331 } |
332 #else | |
333 // optimized version (fixed) as of 2020-04-15 | |
334 unsigned int pitch = writer.GetAccessor().GetPitch(); | |
335 T* targetAddrLine = reinterpret_cast<T*>(writer.GetAccessor().GetRow(0)); | |
336 assert(sizeof(T) == Orthanc::GetBytesPerPixel(target.GetFormat())); | |
337 | |
338 for (unsigned int y = 0; y < height; y++) | |
339 { | |
340 T* targetAddrPix = targetAddrLine; | |
341 for (unsigned int x = 0; x < width; x++) | |
342 { | |
343 CopyPixel(*targetAddrPix, source); | |
344 | |
345 distribution[*targetAddrPix] += 1; | |
346 | |
347 targetAddrPix++; | |
348 source += bpp; | |
349 } | |
350 uint8_t* targetAddrLineBytes = reinterpret_cast<uint8_t*>(targetAddrLine) + pitch; | |
351 targetAddrLine = reinterpret_cast<T*>(targetAddrLineBytes); | |
352 } | |
353 #endif | |
334 } | 354 } |
335 } | 355 } |
336 } | 356 } |
337 | 357 |
338 template <typename T> | 358 template <typename T> |