kfbximageconverter.h

Go to the documentation of this file.
00001 
00004 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXIMAGECONVERTER_H
00005 #define FBXFILESDK_KFBXPLUGINS_KFBXIMAGECONVERTER_H
00006 
00007 /**************************************************************************************
00008 
00009  Copyright (C) 2001 - 2009 Autodesk, Inc. and/or its licensors.
00010  All Rights Reserved.
00011 
00012  The coded instructions, statements, computer programs, and/or related material 
00013  (collectively the "Data") in these files contain unpublished information 
00014  proprietary to Autodesk, Inc. and/or its licensors, which is protected by 
00015  Canada and United States of America federal copyright law and by international 
00016  treaties. 
00017  
00018  The Data may not be disclosed or distributed to third parties, in whole or in
00019  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00020 
00021  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00022  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00023  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00024  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, 
00025  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. 
00026  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00027  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. 
00028  
00029  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00030  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00031  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00032  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00033  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00034  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00035  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00036  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00037  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00038  OR DAMAGE. 
00039 
00040 **************************************************************************************/
00041 
00042 #include <fbxfilesdk/components/kbaselib/kaydaradef_h.h>
00043 #include <fbxfilesdk/components/kbaselib/kaydara.h>
00044 
00045 #include <fbxfilesdk/components/kbaselib/klib/kstring.h>
00046 
00047 #include <fbxfilesdk/components/kbaselib/kbaselib_forward.h>
00048 #include <fbxfilesdk/kfbxplugins/kfbxobject.h>
00049 
00050 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00051 
00052 class KFbxSdkManager;
00053 
00054 const int ColorSpaceRGB = 0;
00055 const int ColorSpaceYUV = 1;
00056 const int FileToBuffer  = 0;
00057 const int BufferToFile  = 1;
00058 
00062 class KFBX_DLL ImageConverterBuffer
00063 {
00064 private:
00065     int     mWidth;         // number of horizontal pixels
00066     int     mHeight;        // number of vertical pixels
00067     int     mColorSpace;    // either RGB or YUV
00068     int     mPixelSize;     // 3 or 4 (case of RGBA)
00069     kByte  *mData;          // pointer to the array of pixels
00070 
00071     bool    mOriginalFormat;    // true if the data in this object has 
00072     KString mOriginalFileName;  // not been converted in any way
00073 
00074     bool    mValid;
00075     bool    mUseDataBuffer;    // if false, the data to use is an external file on disk
00076                                // otherwise the data is the allocated memory buffer.
00077 
00078 public:
00083 
00085     ImageConverterBuffer();
00087     ~ImageConverterBuffer();
00089 
00093     bool    IsValid()               { return mValid; }
00094 
00098     bool    UseDataBuffer()         { return mUseDataBuffer; }
00099 
00103     int     GetWidth()              { return mWidth; }
00104 
00108     int     GetHeight()             { return mHeight; }
00109 
00113     int     GetColorSpace()         { return mColorSpace; }
00114 
00118     char    GetPixelSize()          { return (char) mPixelSize; }
00119 
00123     kByte*  GetData()               { return mData; }
00124 
00128     bool    GetOriginalFormat()     { return mOriginalFormat; }
00129 
00136     KString GetOriginalFileName()   { return mOriginalFileName; }
00137 
00147     void Init(int pWidth, int pHeight, bool pUseDataBuffer, int pColorSpace = ColorSpaceRGB, char pPixelSize = 4);
00148 
00152     void SetOriginalFormat(bool pState);
00153 
00157     void SetOriginalFileName(KString pFilename);
00158 };
00159 
00160 // This function should return 0 if successful and any non zero value otherwise. And should
00161 // init the pBuffer with the correct values.
00162 typedef int (*ImageConverterFunction)(int pDirection, KString& pFileName, ImageConverterBuffer& pBuffer);
00163 
00164 
00166 class KFBX_DLL KFbxImageConverter : public KFbxObject
00167 {
00168     KFBXOBJECT_DECLARE(KFbxImageConverter,KFbxObject);
00169 
00170 public:
00171 
00179     void RegisterConverterFunction(KString pFileExt, ImageConverterFunction pFct);
00180 
00184     void UnregisterConverterFunction(ImageConverterFunction pFct);
00185 
00192     bool Convert(int pDirection, KString& pFileName, ImageConverterBuffer& pBuffer);
00193 
00195 //
00196 //  WARNING!
00197 //
00198 //  Anything beyond these lines may not be documented accurately and is 
00199 //  subject to change without notice.
00200 //
00202 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00203 
00204 protected:
00205 
00206     virtual KFbxObject* Clone( KFbxObject* pContainer, KFbxObject::ECloneType pCloneType ) const;
00207     KFbxImageConverter(KFbxSdkManager& pManager,char const *pName);
00208     virtual void Destruct(bool pRecursive, bool pDependents);
00209 
00210     KFbxImageConverter& operator=( const KFbxImageConverter& pOther );
00211 
00212     KCharPtrSet*    mConverterFunctions;
00213     KFbxSdkManager* mManager;
00214 
00215 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00216 
00217 };
00218 
00219 // global utilities
00220 KFBX_DLL bool IsCompressedTif(KString pFile);
00221 KFBX_DLL bool IsTif(KString pFile);
00222 KFBX_DLL bool ReadFromTif(KString pFile, ImageConverterBuffer& pBuffer, bool deleteFile);
00223 KFBX_DLL bool WriteToTif(KString pFile, bool pCompressed, ImageConverterBuffer& pBuffer);
00224 
00225 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00226 
00227 #endif // FBXFILESDK_KFBXPLUGINS_KFBXIMAGECONVERTER_H
00228