fixed: gcc8 compile issues
[opensg.git] / Source / System / Image / OSGImageFileType.h
blob2b14d78127a138f50016a646715744b4bcafc957
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGIMAGEFILETYPE_H_
40 #define _OSGIMAGEFILETYPE_H_
42 #include <list>
44 #include "OSGIOFileTypeBase.h"
45 #include "OSGImage.h"
46 #include "OSGGeoReferenceAttachment.h"
48 #include "boost/shared_ptr.hpp"
50 OSG_BEGIN_NAMESPACE
52 class ImageFileType;
54 /*! \ingroup GrpSystemImageHelper
55 \ingroup GrpLibOSGSystem
58 class OSG_SYSTEM_DLLMAPPING ImageBlockAccessor
60 /*========================== PUBLIC =================================*/
62 public:
64 /*---------------------------------------------------------------------*/
65 /*! \name Destructor */
66 /*! \{ */
68 virtual ~ImageBlockAccessor(void);
70 /*! \} */
71 /*---------------------------------------------------------------------*/
72 /*! \name Read/Write */
73 /*! \{ */
75 virtual bool isOpen(void) = 0;
77 /*! \} */
78 /*---------------------------------------------------------------------*/
79 /*! \name Read/Write */
80 /*! \{ */
82 Vec2i getSize (void);
84 Image::Type getType (void);
85 Image::PixelFormat getFormat (void);
87 Real64 getNoDataValue(void);
89 /*! \} */
90 /*---------------------------------------------------------------------*/
91 /*! \name Read/Write */
92 /*! \{ */
94 GeoReferenceAttachment *getGeoRef(void);
96 /*! \} */
97 /*---------------------------------------------------------------------*/
98 /*! \name Read/Write */
99 /*! \{ */
101 virtual bool readBlockA16(Vec2i vSampleOrigin,
102 Int32 iTextureSize,
103 UInt16 *pTarget,
104 Int32 iTargetSizeBytes) = 0;
106 virtual bool readBlockA16(Vec2i vSampleOrigin,
107 Int32 iTextureSize,
108 Int16 *pTarget,
109 Int32 iTargetSizeBytes) = 0;
111 /*! \} */
112 /*========================= PROTECTED ===============================*/
114 protected:
116 GeoReferenceAttachmentUnrecPtr _pGeoRef;
117 Vec2i _vSize;
118 Image::Type _eImgType;
119 Image::PixelFormat _eImgFormat;
120 Real64 _fNoDataValue;
122 /*---------------------------------------------------------------------*/
123 /*! \name Default Constructor */
124 /*! \{ */
126 ImageBlockAccessor(void);
128 /*! \} */
129 /*========================== PRIVATE ================================*/
131 private:
134 /*! \ingroup GrpSystemImageHelper
137 typedef boost::shared_ptr<ImageBlockAccessor> ImageBlockAccessorPtr;
139 /*! \ingroup GrpSystemImageHelper
140 \ingroup GrpLibOSGSystem
143 class OSG_SYSTEM_DLLMAPPING BlockAccessWrapper : public ImageBlockAccessor
145 /*========================== PUBLIC =================================*/
147 public:
149 typedef ImageBlockAccessor Inherited;
151 /*---------------------------------------------------------------------*/
152 /*! \name Destructor */
153 /*! \{ */
155 virtual ~BlockAccessWrapper(void);
157 /*! \} */
158 /*---------------------------------------------------------------------*/
159 /*! \name Read/Write */
160 /*! \{ */
162 virtual bool isOpen(void);
164 /*! \} */
165 /*---------------------------------------------------------------------*/
166 /*! \name Read/Write */
167 /*! \{ */
169 /*! \} */
170 /*---------------------------------------------------------------------*/
171 /*! \name Read/Write */
172 /*! \{ */
174 /*! \} */
175 /*---------------------------------------------------------------------*/
176 /*! \name Read/Write */
177 /*! \{ */
179 virtual bool readBlockA16(Vec2i vSampleOrigin,
180 Int32 iTextureSize,
181 UInt16 *pTarget,
182 Int32 iTargetSizeBytes);
184 virtual bool readBlockA16(Vec2i vSampleOrigin,
185 Int32 iTextureSize,
186 Int16 *pTarget,
187 Int32 iTargetSizeBytes);
189 /*! \} */
190 /*========================= PROTECTED ===============================*/
192 protected:
194 ImageUnrecPtr _pImage;
196 /*---------------------------------------------------------------------*/
197 /*! \name Default Constructor */
198 /*! \{ */
200 BlockAccessWrapper(void);
202 /*! \} */
203 /*---------------------------------------------------------------------*/
204 /*! \name Read/Write */
205 /*! \{ */
207 void open(const Char8 *szFilename);
209 /*! \} */
210 /*========================== PRIVATE ================================*/
212 private:
214 friend class ImageFileType;
217 /*! \ingroup GrpSystemImageHelper
220 typedef boost::shared_ptr<BlockAccessWrapper> BlockAccessWrapperPtr;
222 /*! \brief Abstract Base ImageFileType. Defines the Interface for
223 all concrete ImageFileTypes. See \ref PageSystemImage for detailed
224 description.
226 \ingroup GrpSystemImageFileIOBase
227 \ingroup GrpLibOSGSystem
230 class OSG_SYSTEM_DLLMAPPING ImageFileType : public IOFileTypeBase
232 /*========================== PUBLIC =================================*/
233 public:
234 /*---------------------------------------------------------------------*/
235 /*! \name Public Types */
236 /*! \{ */
238 typedef IOFileTypeBase Inherited;
239 typedef ImageFileType Self;
241 /*! \} */
242 /*---------------------------------------------------------------------*/
243 /*! \name Flags */
244 /*! \{ */
246 enum
248 OSG_READ_SUPPORTED = 1,
249 OSG_WRITE_SUPPORTED = 2
252 /*! \} */
253 /*---------------------------------------------------------------------*/
254 /*! \name Destructor */
255 /*! \{ */
257 virtual ~ImageFileType(void);
259 /*! \} */
260 /*---------------------------------------------------------------------*/
261 /*! \name Get Methods */
262 /*! \{ */
264 const Char8 *getMimeType (void) const;
266 const std::list<std::string> &getSuffixList(void) const;
268 /*! \} */
269 /*---------------------------------------------------------------------*/
270 /*! \name Read/Write */
271 /*! \{ */
273 virtual bool read ( Image *pImage,
274 const Char8 *fileName ) ;
276 virtual bool write ( Image const *pImage,
277 const Char8 *fileName ) ;
279 virtual bool read ( Image *pImage,
280 std::istream &is,
281 const std::string &mimetype);
283 virtual bool write ( Image const *pImage,
284 std::ostream &os,
285 const std::string &mimetype);
287 virtual bool validateHeader(const Char8 *fileName,
288 bool &implemented);
290 /*! \} */
291 /*---------------------------------------------------------------------*/
292 /*! \name Read/Write */
293 /*! \{ */
295 virtual ImageBlockAccessorPtr open(const Char8 *fileName);
297 /*! \} */
298 /*---------------------------------------------------------------------*/
299 /*! \name Type */
300 /*! \{ */
302 virtual std::string determineMimetypeFromStream(std::istream &is);
304 /*! \} */
305 /*---------------------------------------------------------------------*/
306 /*! \name static store/restore */
307 /*! \{ */
309 static UInt64 restore( Image *pImage,
310 const UChar8 *buffer,
311 Int32 memSize = -1);
313 static UInt64 store ( Image const *pImage,
314 const Char8 *mimeType,
315 UChar8 *buffer,
316 Int32 memSize = -1);
318 /*! \} */
319 /*---------------------------------------------------------------------*/
320 /*! \name Raw Store/Restore */
321 /*! \{ */
323 virtual UInt64 restoreData( Image *pImage,
324 const UChar8 *buffer,
325 Int32 memSize = -1) const;
327 virtual UInt64 storeData ( Image const *pImage,
328 UChar8 *buffer,
329 Int32 memSize = -1) const;
331 /*! \} */
332 /*---------------------------------------------------------------------*/
333 /*! \name store/restore */
334 /*! \{ */
336 UInt64 store (Image const *pImage,
337 UChar8 *buffer,
338 Int32 memSize = -1);
340 virtual UInt64 maxBufferSize(Image const *pImage );
342 /*! \} */
343 /*---------------------------------------------------------------------*/
344 /*! \name dump */
345 /*! \{ */
347 void dump(void);
349 /*! \} */
350 /*========================= PROTECTED ===============================*/
352 protected:
354 /*---------------------------------------------------------------------*/
355 /*! \name MTD Header */
356 /*! \{ */
358 /*! \nohierarchy
361 struct OSG_SYSTEM_DLLMAPPING Head
363 Char8 suffix[8];
365 unsigned short pixelFormat;
366 unsigned short width;
367 unsigned short height;
368 unsigned short depth;
369 unsigned short mipmapCount;
370 unsigned short frameCount;
371 unsigned short frameDelay;
372 unsigned short sideCount;
373 unsigned short dataType;
374 unsigned short _reserved3;
375 unsigned short _reserved4;
376 unsigned short attachmentSize;
378 bool netToHost(void);
379 bool hostToNet(void);
382 /*! \} */
383 /*---------------------------------------------------------------------*/
384 /*! \name Default Constructor */
385 /*! \{ */
387 ImageFileType(const Char8 *mimeType,
388 const Char8 *suffixArray[],
389 UInt16 suffixByteCount,
390 UInt32 flags = OSG_READ_SUPPORTED);
392 /*! \} */
393 /*========================== PRIVATE ================================*/
395 private:
396 /* prohibit default function (move to 'public' if needed) */
397 ImageFileType (const ImageFileType &obj);
398 const ImageFileType &operator =(const ImageFileType &obj);
401 std::list<std::string> _suffixList;
403 std::string _mimeType;
406 typedef ImageFileType *ImageFileTypeP;
408 OSG_END_NAMESPACE
410 #endif // _OSGIMAGEFILETYPE_H_