mirror of
https://github.com/microsoft/DirectXTex.git
synced 2026-02-04 04:16:12 +01:00
Add Auxiliary files for JPEG/PNG support on Linux (#407)
This commit is contained in:
@@ -64,14 +64,19 @@
|
||||
|
||||
#include "DirectXPackedVector.h"
|
||||
|
||||
//Uncomment to add support for OpenEXR (.exr)
|
||||
//#define USE_OPENEXR
|
||||
|
||||
#ifdef USE_OPENEXR
|
||||
// See <https://github.com/Microsoft/DirectXTex/wiki/Adding-OpenEXR> for details
|
||||
#include "DirectXTexEXR.h"
|
||||
#endif
|
||||
|
||||
// See <https://github.com/Microsoft/DirectXTex/wiki/Using-JPEG-PNG-OSS> for details
|
||||
#ifdef USE_LIBJPEG
|
||||
#include "DirectXTexJPEG.h"
|
||||
#endif
|
||||
#ifdef USE_LIBPNG
|
||||
#include "DirectXTexPNG.h"
|
||||
#endif
|
||||
|
||||
using namespace DirectX;
|
||||
using namespace DirectX::PackedVector;
|
||||
using Microsoft::WRL::ComPtr;
|
||||
@@ -456,14 +461,29 @@ namespace
|
||||
|
||||
#ifdef USE_OPENEXR
|
||||
#define CODEC_EXR 0xFFFF0008
|
||||
#endif
|
||||
#ifdef USE_LIBJPEG
|
||||
#define CODEC_JPEG 0xFFFF0009
|
||||
#endif
|
||||
#ifdef USE_LIBPNG
|
||||
#define CODEC_PNG 0xFFFF000A
|
||||
#endif
|
||||
|
||||
const SValue<uint32_t> g_pSaveFileTypes[] = // valid formats to write to
|
||||
{
|
||||
{ L"bmp", WIC_CODEC_BMP },
|
||||
#ifdef USE_LIBJPEG
|
||||
{ L"jpg", CODEC_JPEG },
|
||||
{ L"jpeg", CODEC_JPEG },
|
||||
#else
|
||||
{ L"jpg", WIC_CODEC_JPEG },
|
||||
{ L"jpeg", WIC_CODEC_JPEG },
|
||||
#endif
|
||||
#ifdef USE_LIBPNG
|
||||
{ L"png", CODEC_PNG },
|
||||
#else
|
||||
{ L"png", WIC_CODEC_PNG },
|
||||
#endif
|
||||
{ L"dds", CODEC_DDS },
|
||||
{ L"ddx", CODEC_DDS },
|
||||
{ L"tga", CODEC_TGA },
|
||||
@@ -2212,6 +2232,30 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_LIBJPEG
|
||||
else if (_wcsicmp(ext.c_str(), L".jpg") == 0 || _wcsicmp(ext.c_str(), L".jpeg") == 0)
|
||||
{
|
||||
hr = LoadFromJPEGFile(curpath.c_str(), &info, *image);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
wprintf(L" FAILED (%08X%ls)\n", static_cast<unsigned int>(hr), GetErrorDesc(hr));
|
||||
retVal = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_LIBPNG
|
||||
else if (_wcsicmp(ext.c_str(), L".png") == 0)
|
||||
{
|
||||
hr = LoadFromPNGFile(curpath.c_str(), &info, *image);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
wprintf(L" FAILED (%08X%ls)\n", static_cast<unsigned int>(hr), GetErrorDesc(hr));
|
||||
retVal = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
@@ -3803,6 +3847,16 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
hr = SaveToEXRFile(img[0], destName.c_str());
|
||||
break;
|
||||
#endif
|
||||
#ifdef USE_LIBJPEG
|
||||
case CODEC_JPEG:
|
||||
hr = SaveToJPEGFile(img[0], destName.c_str());
|
||||
break;
|
||||
#endif
|
||||
#ifdef USE_LIBPNG
|
||||
case CODEC_PNG:
|
||||
hr = SaveToPNGFile(img[0], destName.c_str());
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user