VR-Forces 4.1 Class Documentation
DtMeifConverter.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2010 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: $ $Revision: $ $State: $
7 ******************************************************************************/
8 
12 
13 #pragma once
14 
15 #include <vrvOsg/vrvOsg.h>
16 #include <osg/ref_ptr>
17 #include <osg/Image>
18 #include <vector>
19 
20 namespace makVrv
21 {
25  {
26  public:
27 
29  {
30  std::string filename;
31  int srcX;
32  int srcY;
33  int srcW;
34  int srcH;
35  };
36 
37  typedef std::vector<CompositeImage> ImageList;
38 
41 
43  ~DtMeifConverter();
44 
46  bool createEncryptedImage(const std::string& filename,
47  const std::string& outputFile, bool flipOutputImage, bool normalMap,
48  bool verbose);
49 
51  bool createCompressedImage( osg::ref_ptr<osg::Image> img,
52  const std::string &outputFile, bool flipOutputImage, bool normalMap,
53  bool generateMipMaps, bool verbose );
54 
56  bool compositeImages( const ImageList& files,
57  const std::string& outputFile, int outputWidth, int outputHeight,
58  int cols, int rows, bool forceNoAlpha, bool composeRowsTopToBottom,
59  bool verbose);
60 
62  static bool convertToRGBA( osg::ref_ptr<osg::Image> img,
63  unsigned char*& rgbaPixels, bool& deletePixels, bool verbose );
64 
66  void resizeImagePow2(osg::Image* img);
67 
69  bool createBinaryData( unsigned int compressedFormat,
70  osg::ref_ptr<osg::Image> img, bool mipMaps, bool verbose,
71  unsigned int& blockDataSize, unsigned char*& blockData,
72  bool& deleteBlockData );
73 
74  //From Bit Twiddling Hacks (website)
75  inline static bool isPowerOf2(unsigned int i)
76  {
77  return !( i & (i - 1)) && i;
78  }
79 
80  //From Bit Twiddling Hacks (website)
81  inline static unsigned int nextPowerOf2(unsigned int i)
82  {
83  --i;
84  i |= i >> 1;
85  i |= i >> 2;
86  i |= i >> 4;
87  i |= i >> 8;
88  i |= i >> 16;
89  ++i;
90  return i;
91  }
92 
93  inline static unsigned int logBase2(unsigned int i)
94  {
95  static const int MultiplyDeBruijnBitPosition[32] =
96  {
97  0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
98  8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
99  };
100 
101  return MultiplyDeBruijnBitPosition[((nextPowerOf2(i + 1) - 1) * 0x07C4ACDDU) >> 27];
102  }
103 
104  };
105 }

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)