44 std::string ext = boost::filesystem::extension(path).substr(1);
46 int channels = (int)Ogre::PixelUtil::getComponentCount(image.getFormat());
47 int stride = image.getWidth() * (int)Ogre::PixelUtil::getNumElemBytes(image.getFormat());
51 image.save(path.generic_string());
55 else if (ext ==
"bmp")
57 return (
bool)
stbi_write_bmp(path.generic_string().c_str(), image.getWidth(), image.getHeight(), channels, image.getData());
59 else if (ext ==
"tga")
61 return (
bool)
stbi_write_tga(path.generic_string().c_str(), image.getWidth(), image.getHeight(), channels, image.getData());
63 else if (ext ==
"jpg")
65 return (
bool)
stbi_write_jpg(path.generic_string().c_str(), image.getWidth(), image.getHeight(), channels, image.getData(), 90);
67 else if (ext ==
"hdr")
69 return (
bool)
stbi_write_hdr(path.generic_string().c_str(), image.getWidth(), image.getHeight(), channels, (
const float*)image.getData());
232 Ogre::uint8 r, g, b, a;
238 unsigned char pixelSize = Ogre::PixelUtil::getNumElemBytes(format);
239 for (i = start; i < end; i++)
241 for (j = 0; j < conv.
width; j++)
243 y = (int)(y_ratio * i);
244 x = (int)(x_ratio * j);
245 w = (x_ratio * j) - x;
246 h = (y_ratio * i) - y;
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));
283 Ogre::PixelUtil::packColour(b, g, r, a, format, &((Ogre::uint8*)conv.
dstBuff)[pixelSize * ((i * conv.
width) + j)]);
290 if ((scolBitmap == 0) || (buff == 0))
294 int sbpl = scolBitmap->BPL;
295 int dbpl = scolBitmap->TailleW * 3;
298 memcpy(buff, scolBitmap->bits, scolBitmap->TailleW * scolBitmap->TailleH * scolBitmap->BytesPP);
301 int numthreads = (scolBitmap->TailleH <= 8) ? 1 : std::thread::hardware_concurrency();
302 int rows = scolBitmap->TailleH / numthreads;
303 int extra = scolBitmap->TailleH % numthreads;
309 std::vector<std::thread> thgroup;
310 for (
int t = 1; t <= numthreads; t++)
321 for (
auto& thread : thgroup)
328 if ((scolBitmap == 0) || (pixelbox.data == 0))
331 unsigned char pixelSize = Ogre::PixelUtil::getNumElemBytes(pixelbox.format);
334 int sbpl = scolBitmap->BPL;
335 int abpl = (alphaBitmap != 0) ? alphaBitmap->BPL : 0;
336 int dbpl = pixelSize * pixelbox.rowPitch;
337 uchar* alphaBuff = (alphaBitmap != 0) ? alphaBitmap->bits : 0;
340 if ((scolBitmap->TailleW == pixelbox.getWidth()) && ((scolBitmap->TailleH == pixelbox.getHeight())))
342 if (!alphaBitmap && (sbpl == dbpl) && (pixelbox.format == Ogre::PF_BYTE_BGR))
344 memcpy(pixelbox.data, scolBitmap->bits, scolBitmap->TailleW * scolBitmap->TailleH * scolBitmap->BytesPP);
348 int numthreads = (scolBitmap->TailleH <= 8) ? 1 : std::thread::hardware_concurrency();
349 int rows = scolBitmap->TailleH / numthreads;
350 int extra = scolBitmap->TailleH % numthreads;
354 ConversionTools::SConvertBuffer conv(scolBitmap->bits, alphaBuff, pixelbox.data, scolBitmap->TailleW, scolBitmap->TailleH, sbpl, abpl, dbpl, scolBitmap->BytesPP);
356 std::vector<std::thread> thgroup;
357 for (
int t = 1; t <= numthreads; t++)
368 for (
auto& thread : thgroup)
376 int x_ratio = (int)(((scolBitmap->TailleW - 1) << 16) / pixelbox.getWidth());
377 int y_ratio = (int)(((scolBitmap->TailleH - 1) << 16) / pixelbox.getHeight());
379 int numthreads = (pixelbox.getHeight() <= 8) ? 1 : std::thread::hardware_concurrency();
380 int rows = pixelbox.getHeight() / numthreads;
381 int extra = pixelbox.getHeight() % numthreads;
385 ConversionTools::SConvertBuffer conv(scolBitmap->bits, alphaBuff, pixelbox.data, pixelbox.getWidth(), pixelbox.getHeight(), sbpl, abpl, dbpl, scolBitmap->BytesPP);
387 std::vector<std::thread> thgroup;
388 for (
int t = 1; t <= numthreads; t++)
399 for (
auto& thread : thgroup)
403 float x_ratio = (float)(scolBitmap->TailleW - 1) / (float)pixelbox.getWidth();
404 float y_ratio = (float)(scolBitmap->TailleH - 1) / (float)pixelbox.getHeight();
406 int numthreads = (pixelbox.getHeight() <= 8) ? 1 : std::thread::hardware_concurrency();
407 int rows = pixelbox.getHeight() / numthreads;
408 int extra = pixelbox.getHeight() % numthreads;
412 ConversionTools::SConvertBuffer conv(scolBitmap->bits, alphaBuff, pixelbox.data, pixelbox.getWidth(), pixelbox.getHeight(), sbpl, abpl, dbpl, scolBitmap->BytesPP);
414 std::vector<std::thread> thgroup;
415 for (
int t = 1; t <= numthreads; t++)
426 for (
auto& thread : thgroup)
434 if ((scolBitmap == 0) || (buff == 0))
438 int sbpl = scolBitmap->BPL;
439 int abpl = (alphaBitmap != 0) ? alphaBitmap->BPL : 0;
440 int dbpl = scolBitmap->TailleW;
441 uchar* alphaBuff = (alphaBitmap != 0) ? alphaBitmap->bits : 0;
443 int numthreads = (scolBitmap->TailleH <= 8) ? 1 : std::thread::hardware_concurrency();
444 int rows = scolBitmap->TailleH / numthreads;
445 int extra = scolBitmap->TailleH % numthreads;
449 Ogre::PixelFormat format = Ogre::PF_BYTE_BGRA;
450 ConversionTools::SConvertBuffer conv(scolBitmap->bits, alphaBuff, buff, scolBitmap->TailleW, scolBitmap->TailleH, sbpl, abpl, dbpl, scolBitmap->BytesPP);
452 std::vector<std::thread> thgroup;
453 for (
int t = 1; t <= numthreads; t++)
464 for (
auto& thread : thgroup)
470 if ((scolBitmap == 0) || (buff == 0))
473 unsigned char pixelSize = Ogre::PixelUtil::getNumElemBytes(format);
476 int sbpl = scolBitmap->BPL;
477 int abpl = (alphaBitmap != 0) ? alphaBitmap->BPL : 0;
478 int dbpl = pixelSize * scolBitmap->TailleW;
479 uchar* alphaBuff = (alphaBitmap != 0) ? alphaBitmap->bits : 0;
481 if (!alphaBitmap && (sbpl == dbpl) && (format == Ogre::PF_BYTE_BGR))
483 memcpy(buff, scolBitmap->bits, scolBitmap->TailleW * scolBitmap->TailleH * scolBitmap->BytesPP);
487 int numthreads = (scolBitmap->TailleH <= 8) ? 1 : std::thread::hardware_concurrency();
488 int rows = scolBitmap->TailleH / numthreads;
489 int extra = scolBitmap->TailleH % numthreads;
493 ConversionTools::SConvertBuffer conv(scolBitmap->bits, alphaBuff, buff, scolBitmap->TailleW, scolBitmap->TailleH, sbpl, abpl, dbpl, scolBitmap->BytesPP);
495 std::vector<std::thread> thgroup;
496 for (
int t = 1; t <= numthreads; t++)
507 for (
auto& thread : thgroup)
514 if ((scolBitmap == 0) || (buff == 0))
518 if ((scolBitmap->TailleW ==
nwidth) && ((scolBitmap->TailleH ==
nheight)))
521 unsigned char pixelSize = Ogre::PixelUtil::getNumElemBytes(format);
524 int sbpl = scolBitmap->BPL;
525 int abpl = (alphaBitmap != 0) ? alphaBitmap->BPL : 0;
526 int dbpl =
nwidth * pixelSize;
527 uchar* alphaBuff = (alphaBitmap != 0) ? alphaBitmap->bits : 0;
531 int x_ratio = (int)(((scolBitmap->TailleW - 1) << 16) /
nwidth);
532 int y_ratio = (int)(((scolBitmap->TailleH - 1) << 16) /
nheight);
534 int numthreads = (
nheight <= 8) ? 1 : std::thread::hardware_concurrency();
535 int rows =
nheight / numthreads;
536 int extra =
nheight % numthreads;
542 std::vector<std::thread> thgroup;
543 for (
int t = 1; t <= numthreads; t++)
554 for (
auto& thread : thgroup)
558 float x_ratio = (float)(scolBitmap->TailleW - 1) / (float)
nwidth;
559 float y_ratio = (float)(scolBitmap->TailleH - 1) / (float)
nheight;
561 int numthreads = (
nheight <= 8) ? 1 : std::thread::hardware_concurrency();
562 int rows =
nheight / numthreads;
563 int extra =
nheight % numthreads;
569 std::vector<std::thread> thgroup;
570 for (
int t = 1; t <= numthreads; t++)
581 for (
auto& thread : thgroup)
589 if ((sbuff == 0) || (buff == 0))
592 unsigned char pixelSize = Ogre::PixelUtil::getNumElemBytes(format);
593 int dbpl =
nwidth * pixelSize;
597 int x_ratio = (int)(((swidth - 1) << 16) /
nwidth);
598 int y_ratio = (int)(((sheight - 1) << 16) /
nheight);
600 int numthreads = (
nheight <= 8) ? 1 : std::thread::hardware_concurrency();
601 int rows =
nheight / numthreads;
602 int extra =
nheight % numthreads;
608 std::vector<std::thread> thgroup;
609 for (
int t = 1; t <= numthreads; t++)
620 for (
auto& thread : thgroup)
624 float x_ratio = (float)(swidth - 1) / (float)
nwidth;
625 float y_ratio = (float)(sheight - 1) / (float)
nheight;
627 int numthreads = (
nheight <= 8) ? 1 : std::thread::hardware_concurrency();
628 int rows =
nheight / numthreads;
629 int extra =
nheight % numthreads;
635 std::vector<std::thread> thgroup;
636 for (
int t = 1; t <= numthreads; t++)
647 for (
auto& thread : thgroup)