VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <osgDB/ReaderWriter>
19 #include <vector>
20 
21 namespace makVrv
22 {
26  {
27  public:
28 
30  {
31  std::string filename;
32  int srcX;
33  int srcY;
34  int srcW;
35  int srcH;
36  };
37 
38  typedef std::vector<CompositeImage> ImageList;
39 
42 
44  ~DtMeifConverter();
45 
48  bool createEncryptedImage(const std::string& filename,
49  const std::string& outputFile, const osgDB::ReaderWriter::Options* options,
50  bool flipOutputImage, bool normalMap, bool verbose);
51 
53  bool createCompressedImage( osg::ref_ptr<osg::Image> img,
54  const std::string &outputFile, bool flipOutputImage, bool normalMap,
55  bool generateMipMaps, bool verbose );
56 
58  bool compositeImages( const ImageList& files,
59  const std::string& outputFile, int outputWidth, int outputHeight,
60  int cols, int rows, bool forceNoAlpha, bool composeRowsTopToBottom,
61  bool verbose);
62 
64  static bool convertToRGBA( osg::ref_ptr<osg::Image> img,
65  unsigned char*& rgbaPixels, bool& deletePixels, bool verbose );
66 
68  void resizeImagePow2(osg::Image* img);
69 
71  bool createBinaryData( unsigned int compressedFormat,
72  osg::ref_ptr<osg::Image> img, bool mipMaps, bool verbose,
73  unsigned int& blockDataSize, unsigned char*& blockData,
74  bool& deleteBlockData );
75 
76  //From Bit Twiddling Hacks (website)
77  inline static bool isPowerOf2(unsigned int i)
78  {
79  return !( i & (i - 1)) && i;
80  }
81 
82  //From Bit Twiddling Hacks (website)
83  inline static unsigned int nextPowerOf2(unsigned int i)
84  {
85  --i;
86  i |= i >> 1;
87  i |= i >> 2;
88  i |= i >> 4;
89  i |= i >> 8;
90  i |= i >> 16;
91  ++i;
92  return i;
93  }
94 
95  inline static unsigned int logBase2(unsigned int i)
96  {
97  static const int MultiplyDeBruijnBitPosition[32] =
98  {
99  0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
100  8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
101  };
102 
103  return MultiplyDeBruijnBitPosition[((nextPowerOf2(i + 1) - 1) * 0x07C4ACDDU) >> 27];
104  }
105 
106  };
107 }

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)