diff --git a/DirectXTex/DirectXTexP.h b/DirectXTex/DirectXTexP.h index 197d66a..422e8d3 100644 --- a/DirectXTex/DirectXTexP.h +++ b/DirectXTex/DirectXTexP.h @@ -63,8 +63,6 @@ namespace DirectX DXGI_FORMAT _WICToDXGI( _In_ const GUID& guid ); bool _DXGIToWIC( _In_ DXGI_FORMAT format, _Out_ GUID& guid ); - size_t _WICBitsPerPixel( _In_ REFGUID targetGuid ); - IWICImagingFactory* _GetWIC(); inline WICBitmapDitherType _GetWICDither( _In_ DWORD flags ) diff --git a/DirectXTex/DirectXTexUtil.cpp b/DirectXTex/DirectXTexUtil.cpp index 9486486..e5ce2a0 100644 --- a/DirectXTex/DirectXTexUtil.cpp +++ b/DirectXTex/DirectXTexUtil.cpp @@ -113,34 +113,6 @@ bool _DXGIToWIC( DXGI_FORMAT format, GUID& guid ) return false; } -size_t _WICBitsPerPixel( REFGUID targetGuid ) -{ - IWICImagingFactory* pWIC = _GetWIC(); - if ( !pWIC ) - return 0; - - ScopedObject cinfo; - if ( FAILED( pWIC->CreateComponentInfo( targetGuid, &cinfo ) ) ) - return 0; - - WICComponentType type; - if ( FAILED( cinfo->GetComponentType( &type ) ) ) - return 0; - - if ( type != WICPixelFormat ) - return 0; - - ScopedObject pfinfo; - if ( FAILED( cinfo->QueryInterface( __uuidof(IWICPixelFormatInfo), reinterpret_cast( &pfinfo ) ) ) ) - return 0; - - UINT bpp; - if ( FAILED( pfinfo->GetBitsPerPixel( &bpp ) ) ) - return 0; - - return bpp; -} - IWICImagingFactory* _GetWIC() { static IWICImagingFactory* s_Factory = nullptr; diff --git a/DirectXTex/DirectXTexWIC.cpp b/DirectXTex/DirectXTexWIC.cpp index b47e4e5..6b060c8 100644 --- a/DirectXTex/DirectXTexWIC.cpp +++ b/DirectXTex/DirectXTexWIC.cpp @@ -426,22 +426,8 @@ static HRESULT _EncodeImage( _In_ const Image& image, _In_ DWORD flags, _In_ IWI if ( FAILED(hr) ) return hr; - size_t bpp = _WICBitsPerPixel( targetGuid ); - if ( bpp == 0 ) - return E_FAIL; - - size_t rowPitch = ( image.width * bpp + 7 ) / 8; - size_t slicePitch = rowPitch * image.height; - - std::unique_ptr temp( new uint8_t[ slicePitch ] ); - if ( !temp ) - return E_OUTOFMEMORY; - - hr = FC->CopyPixels( 0, static_cast( rowPitch ), static_cast( slicePitch ), temp.get() ); - if ( FAILED(hr) ) - return hr; - - hr = frame->WritePixels( static_cast( image.height ), static_cast( rowPitch ), static_cast( slicePitch ), temp.get() ); + WICRect rect = { 0, 0, static_cast( image.width ), static_cast( image.height ) }; + hr = frame->WriteSource( FC.Get(), &rect ); if ( FAILED(hr) ) return hr; }