SO3Engine
|
SO3ConversionTools.cpp
Go to the documentation of this file.
53 //return (bool)stbi_write_png(path.generic_string().c_str(), image.getWidth(), image.getHeight(), channels, image.getData(), stride);
57 return (bool)stbi_write_bmp(path.generic_string().c_str(), image.getWidth(), image.getHeight(), channels, image.getData());
61 return (bool)stbi_write_tga(path.generic_string().c_str(), image.getWidth(), image.getHeight(), channels, image.getData());
65 return (bool)stbi_write_jpg(path.generic_string().c_str(), image.getWidth(), image.getHeight(), channels, image.getData(), 90);
69 return (bool)stbi_write_hdr(path.generic_string().c_str(), image.getWidth(), image.getHeight(), channels, (const float*)image.getData());
75 bool ConversionTools::SaveImage(const std::string &filename, int w, int h, int channels, const void *data, int quality)
118 // RGBA colour are encoded by scol as "RR GG BB 0A << 1" in memory ("see SCOLParticle.cpp" of the ZooEngine (!)).
177 void ConversionTools::bitmapsToBuffPf(const int start, const int end, const SConvertBuffer &conv, Ogre::PixelFormat format)
201 void ConversionTools::bitmapsToScaleBuffNearest(const int start, const int end, const SConvertBuffer &conv, Ogre::PixelFormat format, const int x_ratio, const int y_ratio)
228 void ConversionTools::bitmapsToScaleBuffBilinear(const int start, const int end, const SConvertBuffer &conv, Ogre::PixelFormat format, const float x_ratio, const float y_ratio)
278 r = (Ogre::uint8)(A[0] * (1 - w) * (1 - h) + B[0] * (w)* (1 - h) + C[0] * (h)* (1 - w) + D[0] * (w * h));
279 g = (Ogre::uint8)(A[1] * (1 - w) * (1 - h) + B[1] * (w)* (1 - h) + C[1] * (h)* (1 - w) + D[1] * (w * h));
280 b = (Ogre::uint8)(A[2] * (1 - w) * (1 - h) + B[2] * (w)* (1 - h) + C[2] * (h)* (1 - w) + D[2] * (w * h));
281 a = (Ogre::uint8)(A[3] * (1 - w) * (1 - h) + B[3] * (w)* (1 - h) + C[3] * (h)* (1 - w) + D[3] * (w * h));
298 memcpy(buff, scolBitmap->bits, scolBitmap->TailleW * scolBitmap->TailleH * scolBitmap->BytesPP);
307 ConversionTools::SConvertBuffer conv(scolBitmap->bits, 0, buff, scolBitmap->TailleW, scolBitmap->TailleH, sbpl, 1, dbpl, scolBitmap->BytesPP);
326 void ConversionTools::ScolBitmapGetRGBA(PtrObjBitmap scolBitmap, PtrObjBitmap alphaBitmap, const Ogre::PixelBox& pixelbox)
340 if ((scolBitmap->TailleW == pixelbox.getWidth()) && ((scolBitmap->TailleH == pixelbox.getHeight())))
344 memcpy(pixelbox.data, scolBitmap->bits, scolBitmap->TailleW * scolBitmap->TailleH * scolBitmap->BytesPP);
354 ConversionTools::SConvertBuffer conv(scolBitmap->bits, alphaBuff, pixelbox.data, scolBitmap->TailleW, scolBitmap->TailleH, sbpl, abpl, dbpl, scolBitmap->BytesPP);
362 thgroup.emplace_back(std::bind(ConversionTools::bitmapsToBuffPf, start, end, conv, pixelbox.format));
385 ConversionTools::SConvertBuffer conv(scolBitmap->bits, alphaBuff, pixelbox.data, pixelbox.getWidth(), pixelbox.getHeight(), sbpl, abpl, dbpl, scolBitmap->BytesPP);
393 thgroup.emplace_back(std::bind(ConversionTools::bitmapsToScaleBuffNearest, start, end, conv, pixelbox.format, x_ratio, y_ratio));
412 ConversionTools::SConvertBuffer conv(scolBitmap->bits, alphaBuff, pixelbox.data, pixelbox.getWidth(), pixelbox.getHeight(), sbpl, abpl, dbpl, scolBitmap->BytesPP);
420 thgroup.emplace_back(std::bind(ConversionTools::bitmapsToScaleBuffBilinear, start, end, conv, pixelbox.format, x_ratio, y_ratio));
432 void ConversionTools::ScolBitmapGetRGBA(PtrObjBitmap scolBitmap, PtrObjBitmap alphaBitmap, void* buff)
450 ConversionTools::SConvertBuffer conv(scolBitmap->bits, alphaBuff, buff, scolBitmap->TailleW, scolBitmap->TailleH, sbpl, abpl, dbpl, scolBitmap->BytesPP);
468 void ConversionTools::ScolBitmapGetRGBA(PtrObjBitmap scolBitmap, PtrObjBitmap alphaBitmap, Ogre::PixelFormat format, void* buff)
483 memcpy(buff, scolBitmap->bits, scolBitmap->TailleW * scolBitmap->TailleH * scolBitmap->BytesPP);
493 ConversionTools::SConvertBuffer conv(scolBitmap->bits, alphaBuff, buff, scolBitmap->TailleW, scolBitmap->TailleH, sbpl, abpl, dbpl, scolBitmap->BytesPP);
512 void ConversionTools::ScolBitmapGetRGBA(PtrObjBitmap scolBitmap, PtrObjBitmap alphaBitmap, unsigned int nwidth, unsigned int nheight, Ogre::PixelFormat format, void* buff)
540 ConversionTools::SConvertBuffer conv(scolBitmap->bits, alphaBuff, buff, nwidth, nheight, sbpl, abpl, dbpl, scolBitmap->BytesPP);
548 thgroup.emplace_back(std::bind(ConversionTools::bitmapsToScaleBuffNearest, start, end, conv, format, x_ratio, y_ratio));
567 ConversionTools::SConvertBuffer conv(scolBitmap->bits, alphaBuff, buff, nwidth, nheight, sbpl, abpl, dbpl, scolBitmap->BytesPP);
575 thgroup.emplace_back(std::bind(ConversionTools::bitmapsToScaleBuffBilinear, start, end, conv, format, x_ratio, y_ratio));
587 void ConversionTools::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)
614 thgroup.emplace_back(std::bind(ConversionTools::bitmapsToScaleBuffNearest, start, end, conv, format, x_ratio, y_ratio));
641 thgroup.emplace_back(std::bind(ConversionTools::bitmapsToScaleBuffBilinear, start, end, conv, format, x_ratio, y_ratio));
const uchar * srcBuffa
Definition SO3ConversionTools.h:74
const uchar * srcBuff
Definition SO3ConversionTools.h:73
static bool SaveImage(const std::string &filename, int w, int h, int comp, const void *data, int quality=90)
Definition SO3ConversionTools.cpp:75
static void bitmapsToScaleBuffNearest(const int start, const int end, const SConvertBuffer &conv, const Ogre::PixelFormat format, const int x_ratio, const int y_ratio)
Definition SO3ConversionTools.cpp:201
static std::string GetValidImageExtension(std::string ext)
Definition SO3ConversionTools.cpp:34
static Ogre::ColourValue ScolToOgreColorRGB(const int &scolColor)
Definition SO3ConversionTools.cpp:147
static Ogre::ColourValue ScolToOgreColorRGBA(const int &scolColor)
Definition SO3ConversionTools.cpp:126
static float formatFloat(float val)
Definition SO3ConversionTools.cpp:682
static bool SaveOgreImage(Ogre::Image &image, boost::filesystem::path &path)
Definition SO3ConversionTools.cpp:42
static std::string formatFloatToString(double val)
Definition SO3ConversionTools.cpp:700
static void bitmapsToScaleBuffBilinear(const int start, const int end, const SConvertBuffer &conv, const Ogre::PixelFormat format, const float x_ratio, const float y_ratio)
Definition SO3ConversionTools.cpp:228
static int OgreToScolColorRGBA(const Ogre::ColourValue &ogreColor)
Definition SO3ConversionTools.cpp:115
static void bitmapsToBuffPf(const int start, const int end, const SConvertBuffer &conv, const Ogre::PixelFormat format)
Definition SO3ConversionTools.cpp:177
static bool fequal(float a, float b)
Definition SO3ConversionTools.cpp:652
static void ScolBitmapGetRGB(PtrObjBitmap scolBitmap, unsigned char *buff)
Definition SO3ConversionTools.cpp:288
static void bitmapToBuff(const int start, const int end, const SConvertBuffer &conv)
Definition SO3ConversionTools.cpp:157
static void ScolBitmapGetRGBA(PtrObjBitmap scolBitmap, PtrObjBitmap alphaBitmap, const Ogre::PixelBox &pixelbox)
Definition SO3ConversionTools.cpp:326
static int OgreToScolColorRGB(const Ogre::ColourValue &ogreColor)
Definition SO3ConversionTools.cpp:137
static double Roundn(double dValue, int nDecimales)
Definition SO3ConversionTools.cpp:668
Definition SO3DataScol.h:38
STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data)
Definition stb_image_write.h:757
STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality)
Definition stb_image_write.h:1518
STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data)
Definition stb_image_write.h:485
STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes)
Definition stb_image_write.h:1161
STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data)
Definition stb_image_write.h:583
Generated by 1.9.8