1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGIMAGEFILETYPE_H_
40 #define _OSGIMAGEFILETYPE_H_
44 #include "OSGIOFileTypeBase.h"
46 #include "OSGGeoReferenceAttachment.h"
48 #include "boost/shared_ptr.hpp"
54 /*! \ingroup GrpSystemImageHelper
55 \ingroup GrpLibOSGSystem
58 class OSG_SYSTEM_DLLMAPPING ImageBlockAccessor
60 /*========================== PUBLIC =================================*/
64 /*---------------------------------------------------------------------*/
65 /*! \name Destructor */
68 virtual ~ImageBlockAccessor(void);
71 /*---------------------------------------------------------------------*/
72 /*! \name Read/Write */
75 virtual bool isOpen(void) = 0;
78 /*---------------------------------------------------------------------*/
79 /*! \name Read/Write */
84 Image::Type
getType (void);
85 Image::PixelFormat
getFormat (void);
87 Real64
getNoDataValue(void);
90 /*---------------------------------------------------------------------*/
91 /*! \name Read/Write */
94 GeoReferenceAttachment
*getGeoRef(void);
97 /*---------------------------------------------------------------------*/
98 /*! \name Read/Write */
101 virtual bool readBlockA16(Vec2i vSampleOrigin
,
104 Int32 iTargetSizeBytes
) = 0;
106 virtual bool readBlockA16(Vec2i vSampleOrigin
,
109 Int32 iTargetSizeBytes
) = 0;
112 /*========================= PROTECTED ===============================*/
116 GeoReferenceAttachmentUnrecPtr _pGeoRef
;
118 Image::Type _eImgType
;
119 Image::PixelFormat _eImgFormat
;
120 Real64 _fNoDataValue
;
122 /*---------------------------------------------------------------------*/
123 /*! \name Default Constructor */
126 ImageBlockAccessor(void);
129 /*========================== 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 =================================*/
149 typedef ImageBlockAccessor Inherited
;
151 /*---------------------------------------------------------------------*/
152 /*! \name Destructor */
155 virtual ~BlockAccessWrapper(void);
158 /*---------------------------------------------------------------------*/
159 /*! \name Read/Write */
162 virtual bool isOpen(void);
165 /*---------------------------------------------------------------------*/
166 /*! \name Read/Write */
170 /*---------------------------------------------------------------------*/
171 /*! \name Read/Write */
175 /*---------------------------------------------------------------------*/
176 /*! \name Read/Write */
179 virtual bool readBlockA16(Vec2i vSampleOrigin
,
182 Int32 iTargetSizeBytes
);
184 virtual bool readBlockA16(Vec2i vSampleOrigin
,
187 Int32 iTargetSizeBytes
);
190 /*========================= PROTECTED ===============================*/
194 ImageUnrecPtr _pImage
;
196 /*---------------------------------------------------------------------*/
197 /*! \name Default Constructor */
200 BlockAccessWrapper(void);
203 /*---------------------------------------------------------------------*/
204 /*! \name Read/Write */
207 void open(const Char8
*szFilename
);
210 /*========================== 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
226 \ingroup GrpSystemImageFileIOBase
227 \ingroup GrpLibOSGSystem
230 class OSG_SYSTEM_DLLMAPPING ImageFileType
: public IOFileTypeBase
232 /*========================== PUBLIC =================================*/
234 /*---------------------------------------------------------------------*/
235 /*! \name Public Types */
238 typedef IOFileTypeBase Inherited
;
239 typedef ImageFileType Self
;
242 /*---------------------------------------------------------------------*/
248 OSG_READ_SUPPORTED
= 1,
249 OSG_WRITE_SUPPORTED
= 2
253 /*---------------------------------------------------------------------*/
254 /*! \name Destructor */
257 virtual ~ImageFileType(void);
260 /*---------------------------------------------------------------------*/
261 /*! \name Get Methods */
264 const Char8
*getMimeType (void) const;
266 const std::list
<std::string
> &getSuffixList(void) const;
269 /*---------------------------------------------------------------------*/
270 /*! \name Read/Write */
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
,
281 const std::string
&mimetype
);
283 virtual bool write ( Image
const *pImage
,
285 const std::string
&mimetype
);
287 virtual bool validateHeader(const Char8
*fileName
,
291 /*---------------------------------------------------------------------*/
292 /*! \name Read/Write */
295 virtual ImageBlockAccessorPtr
open(const Char8
*fileName
);
298 /*---------------------------------------------------------------------*/
302 virtual std::string
determineMimetypeFromStream(std::istream
&is
);
305 /*---------------------------------------------------------------------*/
306 /*! \name static store/restore */
309 static UInt64
restore( Image
*pImage
,
310 const UChar8
*buffer
,
313 static UInt64
store ( Image
const *pImage
,
314 const Char8
*mimeType
,
319 /*---------------------------------------------------------------------*/
320 /*! \name Raw Store/Restore */
323 virtual UInt64
restoreData( Image
*pImage
,
324 const UChar8
*buffer
,
325 Int32 memSize
= -1) const;
327 virtual UInt64
storeData ( Image
const *pImage
,
329 Int32 memSize
= -1) const;
332 /*---------------------------------------------------------------------*/
333 /*! \name store/restore */
336 UInt64
store (Image
const *pImage
,
340 virtual UInt64
maxBufferSize(Image
const *pImage
);
343 /*---------------------------------------------------------------------*/
350 /*========================= PROTECTED ===============================*/
354 /*---------------------------------------------------------------------*/
355 /*! \name MTD Header */
361 struct OSG_SYSTEM_DLLMAPPING Head
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);
383 /*---------------------------------------------------------------------*/
384 /*! \name Default Constructor */
387 ImageFileType(const Char8
*mimeType
,
388 const Char8
*suffixArray
[],
389 UInt16 suffixByteCount
,
390 UInt32 flags
= OSG_READ_SUPPORTED
);
393 /*========================== 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
;
410 #endif // _OSGIMAGEFILETYPE_H_