VR-Forces Developer's Guide
 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) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
14 #include <osg/ref_ptr>
15 #include <osg/Image>
16 
17 #include <osgDB/ReaderWriter>
18 
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  public:
49 
51  virtual ~DtMeifConverter();
52 
53  private:
55  DtMeifConverter(const DtMeifConverter& other);
57  DtMeifConverter& operator=(const DtMeifConverter& other);
58 
59  public:
62  bool createEncryptedImage(const std::string& filename,
63  const std::string& outputFile, const osgDB::ReaderWriter::Options* options,
64  bool flipOutputImage, EffectTextureType textureType, bool verbose, bool generate_dds);
65 
67  bool createCompressedImage(osg::ref_ptr<osg::Image>& img, const std::string& inputFilename,
68  const std::string& outputFile, bool flipOutputImage, EffectTextureType textureType,
69  bool generateMipMaps, int qualityLevel, bool verbose, bool generate_dds);
70 
72  bool startTBBCompressionTaskIfPossible(osg::Image* image);
73 
74  void resizeImageIfNeeded(osg::ref_ptr<osg::Image>& img);
75 
76  void write_and_compress_dds_data(FILE* file, const struct DDS_HEADER& ddsHeader, unsigned int blockDataSize, unsigned char* blockData);
77 
79  bool compositeImages( const ImageList& files,
80  const std::string& outputFile, int outputWidth, int outputHeight,
81  int cols, int rows, bool forceNoAlpha, bool composeRowsTopToBottom,
82  bool verbose);
83 
85  static bool convertToRGBA( osg::ref_ptr<osg::Image>& img,
86  unsigned char*& rgbaPixels, bool& deletePixels, bool verbose );
87 
89  EffectTextureType effectTextureType(const std::string& filename) const;
90 
91  virtual void setupCompressionFormat(osg::ref_ptr<osg::Image>&img, DtMeifConverter::EffectTextureType textureType, osg::ref_ptr<osg::Texture>& texture);
92 
94  void resizeImagePow2(osg::Image* img, int newW, int newH);
95 
97  bool createBinaryData( unsigned int compressedFormat,
98  osg::ref_ptr<osg::Image>& img, bool mipMaps, int qualityLevel, bool verbose,
99  unsigned int& blockDataSize, unsigned char*& blockData,
100  bool& deleteBlockData, osg::Image::MipmapDataType& mipOffsets);
101 
102  //From Bit Twiddling Hacks (website)
103  inline static bool isPowerOf2(unsigned int i)
104  {
105  return !( i & (i - 1)) && i;
106  }
107 
108  //From Bit Twiddling Hacks (website)
109  inline static unsigned int nextPowerOf2(unsigned int i)
110  {
111  --i;
112  i |= i >> 1;
113  i |= i >> 2;
114  i |= i >> 4;
115  i |= i >> 8;
116  i |= i >> 16;
117  ++i;
118  return i;
119  }
120 
121  inline static unsigned int logBase2(unsigned int i)
122  {
123  static const int MultiplyDeBruijnBitPosition[32] =
124  {
125  0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
126  8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
127  };
128 
129  return MultiplyDeBruijnBitPosition[((nextPowerOf2(i + 1) - 1) * 0x07C4ACDDU) >> 27];
130  }
131 
132 
133  };
134 }
int srcH
Definition: DtMeifConverter.h:42
Definition: DtMeifConverter.h:31
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Class responsible for converting images into MAK encrypted image files.
Definition: DtMeifConverter.h:25
int srcX
Definition: DtMeifConverter.h:39
std::string filename
Definition: DtMeifConverter.h:38
std::vector< CompositeImage > ImageList
Definition: DtMeifConverter.h:45
int srcY
Definition: DtMeifConverter.h:40
static unsigned int logBase2(unsigned int i)
Definition: DtMeifConverter.h:121
int srcW
Definition: DtMeifConverter.h:41
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2 &size, const ImVec2 &uv0=ImVec2(0, 0), const ImVec2 &uv1=ImVec2(1, 1), const ImVec4 &tint_col=ImVec4(1, 1, 1, 1), const ImVec4 &border_col=ImVec4(0, 0, 0, 0))
EffectTextureType
Definition: DtMeifConverter.h:29
Definition: DtMeifConverter.h:32
static unsigned int nextPowerOf2(unsigned int i)
Definition: DtMeifConverter.h:109
Contains DLL export macros.
Definition: DtMeifConverter.h:36
static bool isPowerOf2(unsigned int i)
Definition: DtMeifConverter.h:103

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)