Mercurial > hg > orthanc-webviewer
comparison Plugin/DecodedImageAdapter.cpp @ 31:111689a2c177
fix issue #29
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 24 Jun 2015 16:20:41 +0200 |
parents | 02f7a0400a91 |
children | a6ba21a083e5 |
comparison
equal
deleted
inserted
replaced
30:ad7b6757965a | 31:111689a2c177 |
---|---|
82 if (!ParseUri(type, level, instanceId, uri)) | 82 if (!ParseUri(type, level, instanceId, uri)) |
83 { | 83 { |
84 return false; | 84 return false; |
85 } | 85 } |
86 | 86 |
87 std::string file = "/instances/" + instanceId + "/file"; | 87 ParsedDicomImage image(context_, instanceId); |
88 | |
89 std::string dicom; | |
90 if (!GetStringFromOrthanc(dicom, context_, file)) | |
91 { | |
92 return false; | |
93 } | |
94 | |
95 ParsedDicomImage image(dicom); | |
96 | 88 |
97 Json::Value json; | 89 Json::Value json; |
90 bool ok = false; | |
98 | 91 |
99 if (type == CompressionType_Deflate) | 92 if (type == CompressionType_Deflate) |
100 { | 93 { |
101 if (!image.EncodeUsingDeflate(json, 9)) | 94 ok = image.EncodeUsingDeflate(json, 9); |
102 { | |
103 return false; | |
104 } | |
105 } | 95 } |
106 else if (type == CompressionType_Jpeg) | 96 else if (type == CompressionType_Jpeg) |
107 { | 97 { |
108 if (!image.EncodeUsingJpeg(json, level)) | 98 ok = image.EncodeUsingJpeg(json, level); |
109 { | 99 } |
110 return false; | 100 |
111 } | 101 if (ok) |
102 { | |
103 Json::FastWriter writer; | |
104 content = writer.write(json); | |
105 return true; | |
112 } | 106 } |
113 else | 107 else |
114 { | 108 { |
109 char msg[1024]; | |
110 sprintf(msg, "Unable to decode the following instance: %s", uri.c_str()); | |
111 OrthancPluginLogWarning(context_, msg); | |
115 return false; | 112 return false; |
116 } | 113 } |
117 | |
118 Json::FastWriter writer; | |
119 content = writer.write(json); | |
120 return true; | |
121 } | 114 } |
122 } | 115 } |