MCPcopy Create free account
hub / github.com/crownengine/crown / imageWriteExr

Function imageWriteExr

3rdparty/bimg/src/image.cpp:5546–5681  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5544 }
5545
5546 int32_t imageWriteExr(bx::WriterI* _writer, uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src, TextureFormat::Enum _format, bool _yflip, bx::Error* _err)
5547 {
5548 BX_ERROR_SCOPE(_err);
5549
5550 const uint32_t bpp = getBitsPerPixel(_format);
5551 uint32_t bytesPerChannel = 0;
5552
5553 switch (_format)
5554 {
5555 case TextureFormat::RGBA16F:
5556 bytesPerChannel = 2;
5557 break;
5558
5559 default:
5560 BX_ERROR_SET(_err, BIMG_ERROR, "EXR: Unsupported texture format.");
5561 return 0;
5562 }
5563
5564 int32_t total = 0;
5565 total += bx::write(_writer, "v/1\x01", _err);
5566 total += bx::writeLE(_writer, uint32_t(2), _err);
5567
5568 total += bx::write(_writer, "channels", _err);
5569 total += bx::write(_writer, '\0', _err);
5570 total += bx::write(_writer, "chlist", _err);
5571 total += bx::write(_writer, '\0', _err);
5572 total += bx::writeLE(_writer, uint32_t(18*4+1), _err);
5573
5574 const uint8_t cdata[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 };
5575 // Order is always ABGR order because Photoshop and GIMP ignore these fields and
5576 // assume it's in ABGR order.
5577 total += bx::write(_writer, 'A', _err);
5578 total += bx::write(_writer, cdata, BX_COUNTOF(cdata), _err);
5579 total += bx::write(_writer, 'B', _err);
5580 total += bx::write(_writer, cdata, BX_COUNTOF(cdata), _err);
5581 total += bx::write(_writer, 'G', _err);
5582 total += bx::write(_writer, cdata, BX_COUNTOF(cdata), _err);
5583 total += bx::write(_writer, 'R', _err);
5584 total += bx::write(_writer, cdata, BX_COUNTOF(cdata), _err);
5585 total += bx::write(_writer, '\0', _err);
5586
5587 total += bx::write(_writer, "compression", _err);
5588 total += bx::write(_writer, '\0', _err);
5589 total += bx::write(_writer, "compression", _err);
5590 total += bx::write(_writer, '\0', _err);
5591 total += bx::writeLE(_writer, uint32_t(1), _err);
5592 total += bx::write(_writer, '\0', _err); // no compression
5593
5594 total += bx::write(_writer, "dataWindow", _err);
5595 total += bx::write(_writer, '\0', _err);
5596 total += bx::write(_writer, "box2i", _err);
5597 total += bx::write(_writer, '\0', _err);
5598 total += bx::writeLE(_writer, uint32_t(16), _err);
5599 total += bx::writeRep(_writer, '\0', 8, _err);
5600 total += bx::writeLE(_writer, _width-1, _err);
5601 total += bx::writeLE(_writer, _height-1, _err);
5602
5603 total += bx::write(_writer, "displayWindow", _err);

Callers 1

mainFunction · 0.85

Calls 2

getBitsPerPixelFunction · 0.85
writeFunction · 0.50

Tested by

no test coverage detected