comparison OrthancServer/ParsedDicomFile.cpp @ 853:839be3022203 jpeg

DicomImageInformation
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 06 Jun 2014 11:45:16 +0200
parents 84513f2ee1f3
children 87791ebc1f50
comparison
equal deleted inserted replaced
852:5944b8b80842 853:839be3022203
997 template <typename T> 997 template <typename T>
998 static void ExtractPngImageTruncate(std::string& result, 998 static void ExtractPngImageTruncate(std::string& result,
999 DicomIntegerPixelAccessor& accessor, 999 DicomIntegerPixelAccessor& accessor,
1000 PixelFormat format) 1000 PixelFormat format)
1001 { 1001 {
1002 assert(accessor.GetChannelCount() == 1); 1002 assert(accessor.GetInformation().GetChannelCount() == 1);
1003 1003
1004 PngWriter w; 1004 PngWriter w;
1005 1005
1006 std::vector<T> image(accessor.GetWidth() * accessor.GetHeight(), 0); 1006 std::vector<T> image(accessor.GetInformation().GetWidth() * accessor.GetInformation().GetHeight(), 0);
1007 T* pixel = &image[0]; 1007 T* pixel = &image[0];
1008 for (unsigned int y = 0; y < accessor.GetHeight(); y++) 1008 for (unsigned int y = 0; y < accessor.GetInformation().GetHeight(); y++)
1009 { 1009 {
1010 for (unsigned int x = 0; x < accessor.GetWidth(); x++, pixel++) 1010 for (unsigned int x = 0; x < accessor.GetInformation().GetWidth(); x++, pixel++)
1011 { 1011 {
1012 int32_t v = accessor.GetValue(x, y); 1012 int32_t v = accessor.GetValue(x, y);
1013 if (v < static_cast<int32_t>(std::numeric_limits<T>::min())) 1013 if (v < static_cast<int32_t>(std::numeric_limits<T>::min()))
1014 *pixel = std::numeric_limits<T>::min(); 1014 *pixel = std::numeric_limits<T>::min();
1015 else if (v > static_cast<int32_t>(std::numeric_limits<T>::max())) 1015 else if (v > static_cast<int32_t>(std::numeric_limits<T>::max()))
1017 else 1017 else
1018 *pixel = static_cast<T>(v); 1018 *pixel = static_cast<T>(v);
1019 } 1019 }
1020 } 1020 }
1021 1021
1022 w.WriteToMemory(result, accessor.GetWidth(), accessor.GetHeight(), 1022 w.WriteToMemory(result, accessor.GetInformation().GetWidth(), accessor.GetInformation().GetHeight(),
1023 accessor.GetWidth() * sizeof(T), format, &image[0]); 1023 accessor.GetInformation().GetWidth() * sizeof(T), format, &image[0]);
1024 } 1024 }
1025 1025
1026 1026
1027 void ParsedDicomFile::SaveToMemoryBuffer(std::string& buffer) 1027 void ParsedDicomFile::SaveToMemoryBuffer(std::string& buffer)
1028 { 1028 {