GDCM  2.2.0
gdcmStreamImageReader.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 
19 #ifndef GDCMSTREAMIMAGEREADER_H
20 #define GDCMSTREAMIMAGEREADER_H
21 
22 #include "gdcmPixmapReader.h"
23 #include "gdcmImage.h"
24 #include "gdcmReader.h"
25 #include <iostream>
26 #include "gdcmDataSet.h"
27 
28 namespace gdcm
29 {
30 
31 class MediaStorage;
44 {
45 
46 public:
49 
50 
54  void SetFileName(const char* inFileName);
55  void SetStream(std::istream& inStream);
56 
57  std::vector<unsigned int> GetDimensionsValueForResolution( unsigned int );
58 
67  void DefinePixelExtent(uint16_t inXMin, uint16_t inXMax,
68  uint16_t inYMin, uint16_t inYMax, uint16_t inZMin = 0, uint16_t inZMax = 1);
69 
74  uint32_t DefineProperBufferLength() const;
75 
83  bool Read(void* inReadBuffer, const std::size_t& inBufferLength);
84 
90  bool CanReadImage() const;
91 
92 
96  virtual bool ReadImageInformation();
97 
101  File const & GetFile() const;
102 
103 protected:
104 
105  //contains a reader for being able to ReadUpToTag
106  //however, we don't want the user to be able to call Read
107  //either directly or via a parent class call, so we hide the reader in here.
109 
110  std::streamoff mFileOffset; //the fileoffset for getting header information
111  std::streamoff mFileOffset1;
112  DataSet mHeaderInformation; //all the non-pixel information
113 
114  //for thread safety, these should not be stored here, but should be used
115  //for every read subregion operation.
116  uint16_t mXMin, mYMin, mXMax, mYMax, mZMin, mZMax;
117 
122  //virtual bool ReadImageSubregionRAW(std::ostream& os);
123  virtual bool ReadImageSubregionRAW(char* inReadBuffer, const std::size_t& inBufferLength);
124 
127  bool ReadImageSubregionJpegLS(char* inReadBuffer, const std::size_t& inBufferLength);
128 
129 };
130 //see http://stackoverflow.com/questions/1448467/initializing-a-c-stdistringstream-from-an-in-memory-buffer/1449527#1449527
131 struct OneShotReadBuf : public std::streambuf
132 {
133  OneShotReadBuf(void* s, std::size_t n){
134  char* cast = (char*)s;
135  setg(cast, cast, cast+n);
136  }
137 };
138 
139 } // end namespace gdcm
140 
141 #endif //GDCMSTREAMIMAGEREADER_H
142 

Generated on Wed Jun 13 2012 20:40:37 for GDCM by doxygen 1.8.1
SourceForge.net Logo