kfbximageconverter.h

Go to the documentation of this file.
00001 
00004 #ifndef _FBXSDK_IMAGE_CONVERTER_H_
00005 #define _FBXSDK_IMAGE_CONVERTER_H_
00006 
00007 /**************************************************************************************
00008 
00009  Copyright © 2004 - 2007 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 <kaydaradef.h>
00043 #ifndef KFBX_DLL 
00044     #define KFBX_DLL K_DLLIMPORT
00045 #endif
00046 
00047 #include <kaydara.h>
00048 
00049 #include <klib/kstring.h>
00050 
00051 #ifndef MB_FBXSDK
00052 #include <kbaselib_nsuse.h>
00053 #endif
00054 #include <kbaselib_forward.h>
00055 #include <kfbxplugins/kfbxobject.h>
00056 
00057 #include <fbxfilesdk_nsbegin.h>
00058 
00059 class KFbxSdkManager;
00060 
00061 const int ColorSpaceRGB = 0;
00062 const int ColorSpaceYUV = 1;
00063 const int FileToBuffer  = 0;
00064 const int BufferToFile  = 1;
00065 
00066 class ImageConverterBuffer
00067 {
00068 private:
00069     int     mWidth;         // nb of horizontal pixels
00070     int     mHeight;        // nb of vertical pixels
00071     int     mColorSpace;    // either RGB or YUV
00072     int     mPixelSize;     // 3 or 4 (case of RGBA)
00073     kByte  *mData;          // pointer to the array of pixels
00074 
00075     bool    mOriginalFormat;    // true if the data in this object has 
00076     KString mOriginalFileName;  // not been converted in any way
00077 
00078     bool    mValid;
00079     bool    mUseDataBuffer;    // if false, the data to use is an external file on disk
00080                                // otherwise the data is the allocated memory buffer.
00081 
00082 public:
00083     ImageConverterBuffer();
00084     ~ImageConverterBuffer();
00085 
00089     bool    IsValid()               { return mValid; }
00090 
00094     bool    UseDataBuffer()         { return mUseDataBuffer; }
00095 
00099     int     GetWidth()              { return mWidth; }
00100 
00104     int     GetHeight()             { return mHeight; }
00105 
00109     int     GetColorSpace()         { return mColorSpace; }
00110 
00114     char    GetPixelSize()          { return (char) mPixelSize; }
00115 
00119     kByte*  GetData()               { return mData; }
00120 
00124     bool    GetOriginalFormat()     { return mOriginalFormat; }
00125 
00132     KString GetOriginalFileName()   { return mOriginalFileName; }
00133 
00143     void Init(int pWidth, int pHeight, bool pUseDataBuffer, int pColorSpace = ColorSpaceRGB, char pPixelSize = 4);
00144 
00148     void SetOriginalFormat(bool pState);
00149 
00153     void SetOriginalFileName(KString pFilename);
00154 };
00155 
00156 // This function should return 0 if successful and any non zero value otherwise. And should
00157 // init the pBuffer with the correct values.
00158 typedef int (*ImageConverterFunction)(int pDirection, KString& pFileName, ImageConverterBuffer& pBuffer);
00159 
00160 
00162 class KFBX_DLL KFbxImageConverter : public KFbxObject
00163 {
00164     KFBXOBJECT_DECLARE(KFbxImageConverter);
00165 
00166 public:
00167 
00175     void RegisterConverterFunction(KString pFileExt, ImageConverterFunction pFct);
00176 
00180     void UnregisterConverterFunction(ImageConverterFunction pFct);
00181 
00188     bool Convert(int pDirection, KString& pFileName, ImageConverterBuffer& pBuffer);
00189 
00190 protected:
00192 //
00193 //  WARNING!
00194 //
00195 //  Anything beyond these lines may not be documented accurately and is 
00196 //  subject to change without notice.
00197 //
00199 
00200 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00201 
00202     KFbxImageConverter(KFbxSdkManager& pManager,char const *pName);
00203     ~KFbxImageConverter();
00204 
00205     KCharPtrSet*    mConverterFunctions;
00206     KFbxSdkManager* mManager;
00207 
00208 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00209 
00210 };
00211 
00212 // global utilities
00213 bool IsCompressedTif(KString pFile);
00214 bool ReadFromTif(KString pFile, ImageConverterBuffer& pBuffer, bool deleteFile);
00215 bool WriteToTif(KString pFile, bool pCompressed, ImageConverterBuffer& pBuffer);
00216 
00217 #include <fbxfilesdk_nsend.h>
00218 
00219 #endif // #ifndef _FBXSDK_IMAGE_CONVERTER_H_
00220 
00221