Project

General

Profile

SO3Engine
SO3ConversionTools.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
29#ifndef __SO3CONVERSIONTOOLS_H__
30#define __SO3CONVERSIONTOOLS_H__
31
33
34#include "OGRE/OgreImage.h"
35#include <boost/filesystem.hpp>
36
37//STBI
38#define STB_IMAGE_WRITE_IMPLEMENTATION
39#define STB_IMAGE_WRITE_STATIC
41
42namespace SO3
43{
44
49{
50public:
51 static std::string GetValidImageExtension(std::string ext);
52 static bool SaveOgreImage(Ogre::Image &image, boost::filesystem::path &path);
53 static bool SaveImage(const std::string &filename, int w, int h, int comp, const void *data, int quality = 90);
54
55public:
57 {
58 public:
59 SConvertBuffer(const uchar* _srcBuff, const uchar* _srcBuffa, void* _dstBuff, const int &_width, const int &_height, const int &_sbpl, const int &_abpl, const int &_dbpl, const int &_bpp) :
60 srcBuff(_srcBuff),
61 srcBuffa(_srcBuffa),
62 dstBuff(_dstBuff),
63 width(_width),
64 height(_height),
65 sbpl(_sbpl),
66 abpl(_abpl),
67 dbpl(_dbpl),
68 bpp(_bpp)
69 {}
70
72
73 const uchar* srcBuff;
74 const uchar* srcBuffa;
75 void* dstBuff;
76 const int width;
77 const int height;
78 const int sbpl;
79 const int abpl;
80 const int dbpl;
81 const int bpp;
82 };
83protected:
84private:
85
86public:
89 static int OgreToScolColorRGBA(const Ogre::ColourValue& ogreColor);
90
93 static Ogre::ColourValue ScolToOgreColorRGBA(const int& scolColor);
94
97 static int OgreToScolColorRGB(const Ogre::ColourValue& ogreColor);
98
101 static Ogre::ColourValue ScolToOgreColorRGB(const int& scolColor);
102
105 static void bitmapToBuff(const int start, const int end, const SConvertBuffer &conv);
106
109 static void bitmapsToBuffPf(const int start, const int end, const SConvertBuffer &conv, const Ogre::PixelFormat format);
110
113 static void bitmapsToScaleBuffNearest(const int start, const int end, const SConvertBuffer &conv, const Ogre::PixelFormat format, const int x_ratio, const int y_ratio);
114
117 static void bitmapsToScaleBuffBilinear(const int start, const int end, const SConvertBuffer &conv, const Ogre::PixelFormat format, const float x_ratio, const float y_ratio);
118
121 static void ScolBitmapGetRGB(PtrObjBitmap scolBitmap, unsigned char* buff);
122
125 static void ScolBitmapGetRGBA(PtrObjBitmap scolBitmap, PtrObjBitmap alphaBitmap, const Ogre::PixelBox& pixelbox);
126
129 static void ScolBitmapGetRGBA(PtrObjBitmap scolBitmap, PtrObjBitmap alphaBitmap, void* buff);
130
133 static void ScolBitmapGetRGBA(PtrObjBitmap scolBitmap, PtrObjBitmap alphaBitmap, Ogre::PixelFormat format, void* buff);
134
137 static void ScolBitmapGetRGBA(PtrObjBitmap scolBitmap, PtrObjBitmap alphaBitmap, unsigned int nwidth, unsigned int nheight, Ogre::PixelFormat format, void* buff);
138
141 static void ScolBitmapGetRGBA(const uchar* sbuff, const int swidth, const int sheight, const int sbpp, const int sbpl, unsigned int nwidth, unsigned int nheight, Ogre::PixelFormat format, void* buff);
142
145 static float formatFloat(float val);
146
149 static std::string formatFloatToString(double val);
150
153 static std::string formatFloatToString(float val);
154
157 static double formatFloat(double val);
158
161 static double Roundn(double dValue,int nDecimales);
162
165 static bool fequal(float a, float b);
166
167protected:
168private:
173 static double GetDecExp(int nDec);
174};
175
176}
177
178#endif
librairies include
int nheight
Definition SO3SCOL.cpp:5095
SCOL_EXPORT int cbmachine w
Definition SO3SCOL.cpp:5150
int nwidth
Definition SO3SCOL.cpp:5094
SConvertBuffer(const uchar *_srcBuff, const uchar *_srcBuffa, void *_dstBuff, const int &_width, const int &_height, const int &_sbpl, const int &_abpl, const int &_dbpl, const int &_bpp)
static bool SaveImage(const std::string &filename, int w, int h, int comp, const void *data, int quality=90)
static void bitmapsToScaleBuffNearest(const int start, const int end, const SConvertBuffer &conv, const Ogre::PixelFormat format, const int x_ratio, const int y_ratio)
static std::string GetValidImageExtension(std::string ext)
static Ogre::ColourValue ScolToOgreColorRGB(const int &scolColor)
static Ogre::ColourValue ScolToOgreColorRGBA(const int &scolColor)
static float formatFloat(float val)
static bool SaveOgreImage(Ogre::Image &image, boost::filesystem::path &path)
static std::string formatFloatToString(double val)
static void bitmapsToScaleBuffBilinear(const int start, const int end, const SConvertBuffer &conv, const Ogre::PixelFormat format, const float x_ratio, const float y_ratio)
static int OgreToScolColorRGBA(const Ogre::ColourValue &ogreColor)
static void bitmapsToBuffPf(const int start, const int end, const SConvertBuffer &conv, const Ogre::PixelFormat format)
static bool fequal(float a, float b)
static void ScolBitmapGetRGB(PtrObjBitmap scolBitmap, unsigned char *buff)
static void bitmapToBuff(const int start, const int end, const SConvertBuffer &conv)
static void ScolBitmapGetRGBA(PtrObjBitmap scolBitmap, PtrObjBitmap alphaBitmap, const Ogre::PixelBox &pixelbox)
static int OgreToScolColorRGB(const Ogre::ColourValue &ogreColor)
static double Roundn(double dValue, int nDecimales)