Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages | Examples

Image.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 1996-2005 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 
00019 #ifndef _DWFTK_IMAGE_H
00020 #define _DWFTK_IMAGE_H
00021 
00026 
00027 
00028 #ifndef DWFTK_READ_ONLY
00029 
00030 
00031 
00032 #include "dwfcore/String.h"
00033 #include "dwfcore/BufferInputStream.h"
00034 using namespace DWFCore;
00035 
00036 #include "dwf/publisher/Publisher.h"
00037 
00038 
00039 namespace DWFToolkit
00040 {
00041 
00049 class DWFImage : public DWFPublishableResource
00050 {
00051 
00052 public:
00053 
00054     typedef enum
00055     {
00056         ePreview,
00057         eTexture,
00058         eThumbnail
00059 
00060     } teResourceType;
00061 
00062 public:
00063 
00078     _DWFTK_API
00079     DWFImage( const DWFString& zMIMEType,
00080               teResourceType   eType,
00081               unsigned char    nBitsPerPixel,
00082               double           nWidth,
00083               double           nHeight,
00084               double*          pClipRegion = NULL )
00085         throw()
00086         : _bOwnStream( false )
00087         , _pImageStream( NULL )
00088         , _zMIMEType( zMIMEType )
00089         , _eType( eType )
00090         , _nBitsPerPixel( nBitsPerPixel )
00091         , _nWidth( nWidth )
00092         , _nHeight( nHeight )
00093         , _pClipRegion( pClipRegion )
00094     {;}
00095 
00101     _DWFTK_API
00102     ~DWFImage()
00103         throw()
00104     {
00105         if (_pImageStream && _bOwnStream)
00106         {
00107             DWFCORE_FREE_OBJECT( _pImageStream );
00108         }
00109     }
00110 
00120     _DWFTK_API
00121     void attach( DWFInputStream* pImageStream, bool bOwnStream )
00122         throw()
00123     {
00124         if (_pImageStream && _bOwnStream)
00125         {
00126             DWFCORE_FREE_OBJECT( _pImageStream );
00127             _pImageStream = NULL;
00128         }
00129 
00130         _pImageStream = pImageStream;
00131         _bOwnStream = bOwnStream;
00132     }
00133 
00140     _DWFTK_API
00141     const DWFString& getMIMEType()
00142         throw()
00143     {
00144         return _zMIMEType;
00145     }
00146 
00158     _DWFTK_API
00159     DWFInputStream* getInputStream()
00160         throw( DWFException )
00161     {
00162         if (_pImageStream == NULL)
00163         {
00164             _DWFCORE_THROW( DWFNullPointerException, L"No stream bound to object" );
00165         }
00166 
00167         //
00168         // Wrap this up in a buffer stream
00169         //
00170         return DWFCORE_ALLOC_OBJECT( DWFBufferInputStream(_pImageStream, false) );
00171     }
00172 
00179     _DWFTK_API
00180     teResourceType type() const
00181         throw()
00182     {
00183         return _eType;
00184     }
00185 
00192     _DWFTK_API
00193     unsigned char depth() const
00194         throw()
00195     {
00196         return _nBitsPerPixel;
00197     }
00198 
00205     _DWFTK_API
00206     double width() const
00207         throw()
00208     {
00209         return _nWidth;
00210     }
00211 
00218     _DWFTK_API
00219     double height() const
00220         throw()
00221     {
00222         return _nHeight;
00223     }
00224 
00231     _DWFTK_API
00232     double* clip() const
00233         throw()
00234     {
00235         return _pClipRegion;
00236     }
00237 
00238 private:
00239 
00240     bool                _bOwnStream;
00241     DWFInputStream*     _pImageStream;
00242     DWFString           _zMIMEType;
00243     teResourceType      _eType;
00244     unsigned char       _nBitsPerPixel;
00245     double              _nWidth;
00246     double              _nHeight;
00247     double*             _pClipRegion;
00248 
00249 private:
00250 
00251     //
00252     // Not Implemented
00253     //
00254 
00255     DWFImage();
00256     DWFImage( const DWFImage& );
00257     DWFImage& operator=( const DWFImage& );
00258 };
00259 
00267 class DWFTexture : public DWFImage
00268 {
00269 
00270 public:
00271 
00286     _DWFTK_API
00287     DWFTexture( const DWFString& zName,
00288                 const DWFString& zMIMEType,
00289                 unsigned char    nBitsPerPixel,
00290                 double           nWidth,
00291                 double           nHeight,
00292                 double*          pClipRegion = NULL )
00293         throw()
00294         : DWFImage( zMIMEType,
00295                     eTexture,
00296                     nBitsPerPixel,
00297                     nWidth,
00298                     nHeight,
00299                     pClipRegion )
00300         , _zName( zName )
00301     {;}
00302 
00308     _DWFTK_API
00309     ~DWFTexture()
00310         throw()
00311     {;}
00312 
00319     _DWFTK_API
00320     const DWFString& name() const
00321         throw()
00322     {
00323         return _zName;
00324     }
00325 
00326 private:
00327 
00328     DWFString _zName;
00329 
00330 private:
00331 
00332     //
00333     // Not Implemented
00334     //
00335 
00336     DWFTexture();
00337     DWFTexture( const DWFTexture& );
00338     DWFTexture& operator=( const DWFTexture& );
00339 };
00340 
00341 }
00342 
00343 
00344 #endif
00345 #endif
00346 

Generated on Tue May 17 12:38:50 2005 for Autodesk DWF Toolkit by  doxygen 1.4.1