diff --git a/LibDDS/LibDDS.cpp b/LibDDS/LibDDS.cpp index f33bd61..f138935 100644 --- a/LibDDS/LibDDS.cpp +++ b/LibDDS/LibDDS.cpp @@ -244,11 +244,12 @@ bool ConvertDdsInMemory( // --- Save result ------------------------------------------------------------- auto blob = DirectX::Blob(); auto img = image->GetImage(0, 0, 0); + auto wic_codec = GetWICCodec(options.codec); hr = DirectX::SaveToWICMemory( img, 1, DirectX::WIC_FLAGS_NONE, - GetWICCodec(options.codec), + wic_codec, blob ); if (FAILED(hr)) @@ -261,6 +262,11 @@ bool ConvertDdsInMemory( auto blobNeedsToBeReleased = true; + if (outBuffSize != nullptr) + { + *outBuffSize = blob.GetBufferSize(); + } + if (outBuff != nullptr) { *outBuff = reinterpret_cast(blob.GetBufferPointer()); @@ -277,11 +283,6 @@ bool ConvertDdsInMemory( outImageProperties->format = originalInfo.format; } - if (outBuffSize != nullptr) - { - *outBuffSize = blob.GetBufferSize(); - } - if (blobNeedsToBeReleased) { blob.Release();