![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /****************************************************************************** 00002 ** Copyright (c) 2010 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 /****************************************************************************** 00006 ** $RCSfile: $ $Revision: $ $State: $ 00007 ******************************************************************************/ 00008 00012 00013 #pragma once 00014 00015 #include <vrvOsg/vrvOsg.h> 00016 #include <osg/ref_ptr> 00017 #include <osg/Image> 00018 #include <vector> 00019 00020 namespace makVrv 00021 { 00024 class DT_DLL_VRVOSG DtMeifConverter 00025 { 00026 public: 00027 00028 struct CompositeImage 00029 { 00030 std::string filename; 00031 int srcX; 00032 int srcY; 00033 int srcW; 00034 int srcH; 00035 }; 00036 00037 typedef std::vector<CompositeImage> ImageList; 00038 00040 DtMeifConverter(); 00041 00043 ~DtMeifConverter(); 00044 00046 bool createEncryptedImage(const std::string& filename, 00047 const std::string& outputFile, bool flipOutputImage, bool normalMap, 00048 bool verbose); 00049 00051 bool createCompressedImage( osg::ref_ptr<osg::Image> img, 00052 const std::string &outputFile, bool flipOutputImage, bool normalMap, 00053 bool generateMipMaps, bool verbose ); 00054 00056 bool compositeImages( const ImageList& files, 00057 const std::string& outputFile, int outputWidth, int outputHeight, 00058 int cols, int rows, bool forceNoAlpha, bool composeRowsTopToBottom, 00059 bool verbose); 00060 00062 static bool convertToRGBA( osg::ref_ptr<osg::Image> img, 00063 unsigned char*& rgbaPixels, bool& deletePixels, bool verbose ); 00064 00066 void resizeImagePow2(osg::Image* img); 00067 00069 bool createBinaryData( unsigned int compressedFormat, 00070 osg::ref_ptr<osg::Image> img, bool mipMaps, bool verbose, 00071 unsigned int& blockDataSize, unsigned char*& blockData, 00072 bool& deleteBlockData ); 00073 00074 //From Bit Twiddling Hacks (website) 00075 inline static bool isPowerOf2(unsigned int i) 00076 { 00077 return !( i & (i - 1)) && i; 00078 } 00079 00080 //From Bit Twiddling Hacks (website) 00081 inline static unsigned int nextPowerOf2(unsigned int i) 00082 { 00083 --i; 00084 i |= i >> 1; 00085 i |= i >> 2; 00086 i |= i >> 4; 00087 i |= i >> 8; 00088 i |= i >> 16; 00089 ++i; 00090 return i; 00091 } 00092 00093 inline static unsigned int logBase2(unsigned int i) 00094 { 00095 static const int MultiplyDeBruijnBitPosition[32] = 00096 { 00097 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 00098 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 00099 }; 00100 00101 return MultiplyDeBruijnBitPosition[((nextPowerOf2(i + 1) - 1) * 0x07C4ACDDU) >> 27]; 00102 } 00103 00104 }; 00105 }