comparison Core/Images/PamReader.h @ 3834:219de90c1f43

Added a flag to use an extra buffer in PamReader to ensure (malloc-like) alignment of the image buffer. This flag is NOT turned on by default and, in Orthanc, is only used by the Unit tests.
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 15 Apr 2020 16:58:28 +0200
parents 94f4a18a79cc
children 95083d2f6819
comparison
equal deleted inserted replaced
3831:83ea6939293d 3834:219de90c1f43
44 class PamReader : public ImageAccessor 44 class PamReader : public ImageAccessor
45 { 45 {
46 private: 46 private:
47 void ParseContent(); 47 void ParseContent();
48 48
49 /**
50 Whether we want to use the default malloc alignment in the image buffer,
51 at the expense of an extra copy
52 */
53 bool enforceAligned_;
54
55 /**
56 This is actually a copy of wrappedContent_, but properly aligned.
57
58 It is only used if the enforceAligned parameter is set to true in the
59 constructor.
60 */
61 void* alignedImageBuffer_;
62
63 /**
64 Points somewhere in the content_ buffer.
65 */
66 ImageAccessor wrappedContent_;
67
68 /**
69 Raw content (file bytes or answer from the server, for instance).
70 */
49 std::string content_; 71 std::string content_;
50 72
51 public: 73 public:
74 /**
75 See doc for field enforceAligned_
76 */
77 PamReader(bool enforceAligned = false) :
78 enforceAligned_(enforceAligned),
79 alignedImageBuffer_(NULL)
80 {
81 }
82
83 virtual ~PamReader()
84 {
85 // freeing NULL is OK
86 free(alignedImageBuffer_);
87 }
52 88
53 #if ORTHANC_SANDBOXED == 0 89 #if ORTHANC_SANDBOXED == 0
54 void ReadFromFile(const std::string& filename); 90 void ReadFromFile(const std::string& filename);
55 #endif 91 #endif
56 92