gdcm/gdcm-2.0.18-charls.patch

51 lines
1.7 KiB
Diff
Raw Normal View History

2011-11-02 14:44:51 +00:00
diff -up gdcm-2.0.18/Examples/Cxx/FixJAIBugJPEGLS.cxx.charls gdcm-2.0.18/Examples/Cxx/FixJAIBugJPEGLS.cxx
--- gdcm-2.0.18/Examples/Cxx/FixJAIBugJPEGLS.cxx.charls 2011-06-29 01:08:45.000000000 -0600
2011-11-02 15:16:18 +00:00
+++ gdcm-2.0.18/Examples/Cxx/FixJAIBugJPEGLS.cxx 2011-11-02 09:15:59.630494712 -0600
2011-11-02 14:44:51 +00:00
@@ -17,8 +17,7 @@
#include <fstream>
-#include "gdcmcharls/stdafx.h"
-#include "gdcmcharls/interface.h"
+#include "gdcm_charls.h"
/*
* This small example should show how one can handle the famous JAI-JPEGLS bug
@@ -67,7 +66,11 @@ int main(int argc, char *argv[])
char *buffer = &vbuffer[0];
sf->GetBuffer(buffer, totalLen);
+#ifdef GDCM_USE_SYSTEM_CHARLS
+ JlsParameters metadata;
+#else
JlsParamaters metadata;
+#endif
if (JpegLsReadHeader(buffer, totalLen, &metadata) != OK)
{
std::cerr << "Cant parse jpegls" << std::endl;
2011-11-02 15:16:18 +00:00
@@ -156,15 +159,24 @@ int main(int argc, char *argv[])
const char *pbyteCompressed = &vbuffer[0];
unsigned int cbyteCompressed = vbuffer.size(); // updated legnth
+#ifdef GDCM_USE_SYSTEM_CHARLS
+ JlsParameters params = {0};
+#else
JlsParamaters params = {0};
+#endif
JpegLsReadHeader(pbyteCompressed, cbyteCompressed, &params);
std::vector<BYTE> rgbyteOut;
2011-11-02 15:16:18 +00:00
//rgbyteOut.resize( image.GetBufferLength() );
rgbyteOut.resize(params.height *params.width * ((params.bitspersample + 7) / 8) * params.components);
+#ifdef GDCM_USE_SYSTEM_CHARLS
+ JLS_ERROR result =
+ JpegLsDecode(&rgbyteOut[0], rgbyteOut.size(), pbyteCompressed, cbyteCompressed, &params );
+#else
JLS_ERROR result =
JpegLsDecode(&rgbyteOut[0], rgbyteOut.size(), pbyteCompressed, cbyteCompressed );
+#endif
if (result != OK)
{
std::cerr << "Could not patch JAI-JPEGLS" << std::endl;