# HG changeset patch # User Benjamin Golinvaux # Date 1580815935 -3600 # Node ID 29cdd73d947762b39d6cf9ca7956725c3f42903e # Parent 5428b8594382942f7de94db141e0791bdc24e147 DO NOT MERGE! Added global bool that enables dumping the loaded texture histogram. diff -r 5428b8594382 -r 29cdd73d9477 Framework/Scene2D/Internals/OpenGLLookupTableTextureRenderer.cpp --- a/Framework/Scene2D/Internals/OpenGLLookupTableTextureRenderer.cpp Tue Feb 04 12:31:36 2020 +0100 +++ b/Framework/Scene2D/Internals/OpenGLLookupTableTextureRenderer.cpp Tue Feb 04 12:32:15 2020 +0100 @@ -23,6 +23,9 @@ #include + +int OrthancStone_Internals_dump_LoadTexture_histogram = 0; + namespace OrthancStone { namespace Internals @@ -75,6 +78,18 @@ target.GetFormat() == Orthanc::PixelFormat_RGBA32 && sizeof(float) == 4); + + std::map debugHistogram; + if (OrthancStone_Internals_dump_LoadTexture_histogram == 1) + { + for (int i = 0; i <= 255; ++i) + { + uint8_t k = static_cast(i); + debugHistogram[k] = 0; + } + } + + for (unsigned int y = 0; y < height; y++) { const float* p = reinterpret_cast(source.GetConstRow(y)); @@ -94,6 +109,9 @@ uint8_t vv = static_cast(v); + if(OrthancStone_Internals_dump_LoadTexture_histogram == 1) + debugHistogram[vv] += 1; + q[0] = lut[4 * vv + 0]; // R q[1] = lut[4 * vv + 1]; // G q[2] = lut[4 * vv + 2]; // B @@ -103,6 +121,25 @@ q += 4; } } + + if (OrthancStone_Internals_dump_LoadTexture_histogram == 1) + { + uint8_t vv; + LOG(INFO) << "Dumping texture loaded with OpenGLLookupTableTextureRenderer::LoadTexture"; + for (int i = 0; i <= 255; ++i) + { + vv = static_cast(i); + int ivv = vv; + int count = debugHistogram[vv]; + int lutr = lut[4 * vv + 0]; + int lutg = lut[4 * vv + 1]; + int lutb = lut[4 * vv + 2]; + int luta = lut[4 * vv + 3]; + + LOG(ERROR) << "This is no error! Y= " << ivv << " count= " << count + << " lut R= " << lutr << " lut G= " << lutg << " lut B= " << lutb << " lut A= " << luta; + } + } } context_.MakeCurrent();