Image.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 1996-2006 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                 _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00051 {
00052 
00053 public:
00054 
00055     typedef enum
00056     {
00057         ePreview,
00058         eOverlayPreview,
00059         eMarkupPreview,
00060         eTexture,
00061         eThumbnail,
00062         eIcon,
00063         eRasterOverlay,
00064         eRasterMarkup
00065     } teResourceType;
00066 
00067 public:
00068 
00083     _DWFTK_API
00084     DWFImage( const DWFString& zMIMEType,
00085               teResourceType   eType,
00086               unsigned char    nBitsPerPixel,
00087               double           nWidth,
00088               double           nHeight,
00089               double*          pClipRegion = NULL )
00090         throw()
00091         : _bOwnStream( false )
00092         , _pImageStream( NULL )
00093         , _zMIMEType( zMIMEType )
00094         , _eType( eType )
00095         , _nBitsPerPixel( nBitsPerPixel )
00096         , _nWidth( nWidth )
00097         , _nHeight( nHeight )
00098         , _pClipRegion( pClipRegion )
00099     {;}
00100 
00106     _DWFTK_API
00107     ~DWFImage()
00108         throw()
00109     {
00110         if (_pImageStream && _bOwnStream)
00111         {
00112             DWFCORE_FREE_OBJECT( _pImageStream );
00113         }
00114     }
00115 
00125     _DWFTK_API
00126     void attach( DWFInputStream* pImageStream, bool bOwnStream )
00127         throw( DWFException )
00128     {
00129         if (_pImageStream && _bOwnStream)
00130         {
00131             DWFCORE_FREE_OBJECT( _pImageStream );
00132             _pImageStream = NULL;
00133         }
00134 
00135         _pImageStream = pImageStream;
00136         _bOwnStream = bOwnStream;
00137     }
00138 
00145     _DWFTK_API
00146     const DWFString& getMIMEType()
00147         throw()
00148     {
00149         return _zMIMEType;
00150     }
00151 
00163     _DWFTK_API
00164     DWFInputStream* getInputStream()
00165         throw( DWFException )
00166     {
00167         if (_pImageStream == NULL)
00168         {
00169             _DWFCORE_THROW( DWFNullPointerException, /*NOXLATE*/L"No stream bound to object" );
00170         }
00171 
00172         //
00173         // Wrap this up in a buffer stream
00174         //
00175         return DWFCORE_ALLOC_OBJECT( DWFBufferInputStream(_pImageStream, false) );
00176     }
00177 
00184     _DWFTK_API
00185     teResourceType type() const
00186         throw()
00187     {
00188         return _eType;
00189     }
00190 
00197     _DWFTK_API
00198     unsigned char depth() const
00199         throw()
00200     {
00201         return _nBitsPerPixel;
00202     }
00203 
00210     _DWFTK_API
00211     double width() const
00212         throw()
00213     {
00214         return _nWidth;
00215     }
00216 
00223     _DWFTK_API
00224     double height() const
00225         throw()
00226     {
00227         return _nHeight;
00228     }
00229 
00236     _DWFTK_API
00237     double* clip() const
00238         throw()
00239     {
00240         return _pClipRegion;
00241     }
00242 
00243 private:
00244 
00245     bool                _bOwnStream;
00246     DWFInputStream*     _pImageStream;
00247     DWFString           _zMIMEType;
00248     teResourceType      _eType;
00249     unsigned char       _nBitsPerPixel;
00250     double              _nWidth;
00251     double              _nHeight;
00252     double*             _pClipRegion;
00253 
00254 private:
00255 
00256     //
00257     // Not Implemented
00258     //
00259 
00260     DWFImage();
00261     DWFImage( const DWFImage& );
00262     DWFImage& operator=( const DWFImage& );
00263 };
00264 
00272 class DWFTexture : public DWFImage
00273                    _DWFTK_EXPORT_API_MEMORY_CONTROL_BASE_MEMBER
00274 {
00275 
00276 public:
00277 
00292     _DWFTK_API
00293     DWFTexture( const DWFString& zName,
00294                 const DWFString& zMIMEType,
00295                 unsigned char    nBitsPerPixel,
00296                 double           nWidth,
00297                 double           nHeight,
00298                 double*          pClipRegion = NULL )
00299         throw()
00300         : DWFImage( zMIMEType,
00301                     eTexture,
00302                     nBitsPerPixel,
00303                     nWidth,
00304                     nHeight,
00305                     pClipRegion )
00306         , _zName( zName )
00307     {;}
00308 
00314     _DWFTK_API
00315     ~DWFTexture()
00316         throw()
00317     {;}
00318 
00325     _DWFTK_API
00326     const DWFString& name() const
00327         throw()
00328     {
00329         return _zName;
00330     }
00331 
00332 private:
00333 
00334     DWFString _zName;
00335 
00336 private:
00337 
00338     //
00339     // Not Implemented
00340     //
00341 
00342     DWFTexture();
00343     DWFTexture( const DWFTexture& );
00344     DWFTexture& operator=( const DWFTexture& );
00345 };
00346 
00347 }
00348 
00349 
00350 #endif
00351 #endif
00352 

Generated on Tue Jan 6 22:40:03 2009 for Autodesk DWF Toolkit by  doxygen 1.4.5