VR-Forces 4.6.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtMeifConverter.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2018 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  {
33  Emissive
34  };
35 
37  {
38  std::string filename;
39  int srcX;
40  int srcY;
41  int srcW;
42  int srcH;
43  };
44 
45  typedef std::vector<CompositeImage> ImageList;
46 
49 
51  virtual ~DtMeifConverter();
52 
55  bool createEncryptedImage(const std::string& filename,
56  const std::string& outputFile, const osgDB::ReaderWriter::Options* options,
57  bool flipOutputImage, EffectTextureType textureType, bool verbose, bool generate_dds);
58 
60  bool createCompressedImage(osg::ref_ptr<osg::Image> img, const std::string& inputFilename,
61  const std::string &outputFile, bool flipOutputImage, EffectTextureType textureType,
62  bool generateMipMaps, int qualityLevel, bool verbose, bool generate_dds);
63 
64  void resizeImageIfNeeded(osg::ref_ptr<osg::Image> img);
65 
66  void write_and_compress_dds_data(FILE* file, const struct DDS_HEADER & ddsHeader, unsigned int blockDataSize, unsigned char* blockData);
67 
69  bool compositeImages( const ImageList& files,
70  const std::string& outputFile, int outputWidth, int outputHeight,
71  int cols, int rows, bool forceNoAlpha, bool composeRowsTopToBottom,
72  bool verbose);
73 
75  static bool convertToRGBA( osg::ref_ptr<osg::Image> img,
76  unsigned char*& rgbaPixels, bool& deletePixels, bool verbose );
77 
79  EffectTextureType effectTextureType(const std::string& filename) const;
80 
81  virtual void setupCompressionFormat(osg::ref_ptr<osg::Image> img, DtMeifConverter::EffectTextureType textureType, osg::ref_ptr<osg::Texture>& texture);
82 
84  void resizeImagePow2(osg::Image* img, int newW, int newH);
85 
87  bool createBinaryData( unsigned int compressedFormat,
88  osg::ref_ptr<osg::Image> img, bool mipMaps, int qualityLevel, bool verbose,
89  unsigned int& blockDataSize, unsigned char*& blockData,
90  bool& deleteBlockData, osg::Image::MipmapDataType & mipOffsets);
91 
92  //From Bit Twiddling Hacks (website)
93  inline static bool isPowerOf2(unsigned int i)
94  {
95  return !( i & (i - 1)) && i;
96  }
97 
98  //From Bit Twiddling Hacks (website)
99  inline static unsigned int nextPowerOf2(unsigned int i)
100  {
101  --i;
102  i |= i >> 1;
103  i |= i >> 2;
104  i |= i >> 4;
105  i |= i >> 8;
106  i |= i >> 16;
107  ++i;
108  return i;
109  }
110 
111  inline static unsigned int logBase2(unsigned int i)
112  {
113  static const int MultiplyDeBruijnBitPosition[32] =
114  {
115  0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
116  8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
117  };
118 
119  return MultiplyDeBruijnBitPosition[((nextPowerOf2(i + 1) - 1) * 0x07C4ACDDU) >> 27];
120  }
121 
122 
123  };
124 }

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)