mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-13 21:50:13 +02:00
DirectXTK/DirectXTex: Minor code review feedback
This commit is contained in:
parent
177351faa2
commit
32b06b3e5c
@ -723,7 +723,7 @@ static void EncodeSolidBC1(_Out_ D3DX_BC1 *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK)
|
||||
_Use_decl_annotations_
|
||||
void D3DXDecodeBC1(XMVECTOR *pColor, const uint8_t *pBC)
|
||||
{
|
||||
const D3DX_BC1 *pBC1 = reinterpret_cast<const D3DX_BC1 *>(pBC);
|
||||
auto pBC1 = reinterpret_cast<const D3DX_BC1 *>(pBC);
|
||||
DecodeBC1( pColor, pBC1, true );
|
||||
}
|
||||
|
||||
@ -784,7 +784,7 @@ void D3DXEncodeBC1(uint8_t *pBC, const XMVECTOR *pColor, float alphaRef, DWORD f
|
||||
}
|
||||
}
|
||||
|
||||
D3DX_BC1 *pBC1 = reinterpret_cast<D3DX_BC1 *>(pBC);
|
||||
auto pBC1 = reinterpret_cast<D3DX_BC1 *>(pBC);
|
||||
EncodeBC1(pBC1, Color, true, alphaRef, flags);
|
||||
}
|
||||
|
||||
@ -798,7 +798,7 @@ void D3DXDecodeBC2(XMVECTOR *pColor, const uint8_t *pBC)
|
||||
assert( pColor && pBC );
|
||||
static_assert( sizeof(D3DX_BC2) == 16, "D3DX_BC2 should be 16 bytes" );
|
||||
|
||||
const D3DX_BC2 *pBC2 = reinterpret_cast<const D3DX_BC2 *>(pBC);
|
||||
auto pBC2 = reinterpret_cast<const D3DX_BC2 *>(pBC);
|
||||
|
||||
// RGB part
|
||||
DecodeBC1(pColor, &pBC2->bc1, false);
|
||||
@ -827,7 +827,7 @@ void D3DXEncodeBC2(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags)
|
||||
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>( &Color[i] ), pColor[i] );
|
||||
}
|
||||
|
||||
D3DX_BC2 *pBC2 = reinterpret_cast<D3DX_BC2 *>(pBC);
|
||||
auto pBC2 = reinterpret_cast<D3DX_BC2 *>(pBC);
|
||||
|
||||
// 4-bit alpha part. Dithered using Floyd Stienberg error diffusion.
|
||||
pBC2->bitmap[0] = 0;
|
||||
@ -898,7 +898,7 @@ void D3DXDecodeBC3(XMVECTOR *pColor, const uint8_t *pBC)
|
||||
assert( pColor && pBC );
|
||||
static_assert( sizeof(D3DX_BC3) == 16, "D3DX_BC3 should be 16 bytes" );
|
||||
|
||||
const D3DX_BC3 *pBC3 = reinterpret_cast<const D3DX_BC3 *>(pBC);
|
||||
auto pBC3 = reinterpret_cast<const D3DX_BC3 *>(pBC);
|
||||
|
||||
// RGB part
|
||||
DecodeBC1(pColor, &pBC3->bc1, false);
|
||||
@ -946,7 +946,7 @@ void D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags)
|
||||
XMStoreFloat4( reinterpret_cast<XMFLOAT4*>( &Color[i] ), pColor[i] );
|
||||
}
|
||||
|
||||
D3DX_BC3 *pBC3 = reinterpret_cast<D3DX_BC3 *>(pBC);
|
||||
auto pBC3 = reinterpret_cast<D3DX_BC3 *>(pBC);
|
||||
|
||||
// Quantize block to A8, using Floyd Stienberg error diffusion. This
|
||||
// increases the chance that colors will map directly to the quantized
|
||||
|
@ -375,7 +375,7 @@ void D3DXDecodeBC4U( XMVECTOR *pColor, const uint8_t *pBC )
|
||||
assert( pColor && pBC );
|
||||
static_assert( sizeof(BC4_UNORM) == 8, "BC4_UNORM should be 8 bytes" );
|
||||
|
||||
const BC4_UNORM * pBC4 = reinterpret_cast<const BC4_UNORM*>(pBC);
|
||||
auto pBC4 = reinterpret_cast<const BC4_UNORM*>(pBC);
|
||||
|
||||
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
|
||||
{
|
||||
@ -389,7 +389,7 @@ void D3DXDecodeBC4S(XMVECTOR *pColor, const uint8_t *pBC)
|
||||
assert( pColor && pBC );
|
||||
static_assert( sizeof(BC4_SNORM) == 8, "BC4_SNORM should be 8 bytes" );
|
||||
|
||||
const BC4_SNORM * pBC4 = reinterpret_cast<const BC4_SNORM*>(pBC);
|
||||
auto pBC4 = reinterpret_cast<const BC4_SNORM*>(pBC);
|
||||
|
||||
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
|
||||
{
|
||||
@ -406,7 +406,7 @@ void D3DXEncodeBC4U( uint8_t *pBC, const XMVECTOR *pColor, DWORD flags )
|
||||
static_assert( sizeof(BC4_UNORM) == 8, "BC4_UNORM should be 8 bytes" );
|
||||
|
||||
memset(pBC, 0, sizeof(BC4_UNORM));
|
||||
BC4_UNORM * pBC4 = reinterpret_cast<BC4_UNORM*>(pBC);
|
||||
auto pBC4 = reinterpret_cast<BC4_UNORM*>(pBC);
|
||||
float theTexelsU[NUM_PIXELS_PER_BLOCK];
|
||||
|
||||
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
|
||||
@ -427,7 +427,7 @@ void D3DXEncodeBC4S( uint8_t *pBC, const XMVECTOR *pColor, DWORD flags )
|
||||
static_assert( sizeof(BC4_SNORM) == 8, "BC4_SNORM should be 8 bytes" );
|
||||
|
||||
memset(pBC, 0, sizeof(BC4_UNORM));
|
||||
BC4_SNORM * pBC4 = reinterpret_cast<BC4_SNORM*>(pBC);
|
||||
auto pBC4 = reinterpret_cast<BC4_SNORM*>(pBC);
|
||||
float theTexelsU[NUM_PIXELS_PER_BLOCK];
|
||||
|
||||
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
|
||||
@ -449,8 +449,8 @@ void D3DXDecodeBC5U(XMVECTOR *pColor, const uint8_t *pBC)
|
||||
assert( pColor && pBC );
|
||||
static_assert( sizeof(BC4_UNORM) == 8, "BC4_UNORM should be 8 bytes" );
|
||||
|
||||
const BC4_UNORM * pBCR = reinterpret_cast<const BC4_UNORM*>(pBC);
|
||||
const BC4_UNORM * pBCG = reinterpret_cast<const BC4_UNORM*>(pBC+sizeof(BC4_UNORM));
|
||||
auto pBCR = reinterpret_cast<const BC4_UNORM*>(pBC);
|
||||
auto pBCG = reinterpret_cast<const BC4_UNORM*>(pBC+sizeof(BC4_UNORM));
|
||||
|
||||
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
|
||||
{
|
||||
@ -464,8 +464,8 @@ void D3DXDecodeBC5S(XMVECTOR *pColor, const uint8_t *pBC)
|
||||
assert( pColor && pBC );
|
||||
static_assert( sizeof(BC4_SNORM) == 8, "BC4_SNORM should be 8 bytes" );
|
||||
|
||||
const BC4_SNORM * pBCR = reinterpret_cast<const BC4_SNORM*>(pBC);
|
||||
const BC4_SNORM * pBCG = reinterpret_cast<const BC4_SNORM*>(pBC+sizeof(BC4_SNORM));
|
||||
auto pBCR = reinterpret_cast<const BC4_SNORM*>(pBC);
|
||||
auto pBCG = reinterpret_cast<const BC4_SNORM*>(pBC+sizeof(BC4_SNORM));
|
||||
|
||||
for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i)
|
||||
{
|
||||
@ -482,8 +482,8 @@ void D3DXEncodeBC5U( uint8_t *pBC, const XMVECTOR *pColor, DWORD flags )
|
||||
static_assert( sizeof(BC4_UNORM) == 8, "BC4_UNORM should be 8 bytes" );
|
||||
|
||||
memset(pBC, 0, sizeof(BC4_UNORM)*2);
|
||||
BC4_UNORM * pBCR = reinterpret_cast<BC4_UNORM*>(pBC);
|
||||
BC4_UNORM * pBCG = reinterpret_cast<BC4_UNORM*>(pBC+sizeof(BC4_UNORM));
|
||||
auto pBCR = reinterpret_cast<BC4_UNORM*>(pBC);
|
||||
auto pBCG = reinterpret_cast<BC4_UNORM*>(pBC+sizeof(BC4_UNORM));
|
||||
float theTexelsU[NUM_PIXELS_PER_BLOCK];
|
||||
float theTexelsV[NUM_PIXELS_PER_BLOCK];
|
||||
|
||||
@ -516,8 +516,8 @@ void D3DXEncodeBC5S( uint8_t *pBC, const XMVECTOR *pColor, DWORD flags )
|
||||
static_assert( sizeof(BC4_SNORM) == 8, "BC4_SNORM should be 8 bytes" );
|
||||
|
||||
memset(pBC, 0, sizeof(BC4_UNORM)*2);
|
||||
BC4_SNORM * pBCR = reinterpret_cast<BC4_SNORM*>(pBC);
|
||||
BC4_SNORM * pBCG = reinterpret_cast<BC4_SNORM*>(pBC+sizeof(BC4_SNORM));
|
||||
auto pBCR = reinterpret_cast<BC4_SNORM*>(pBC);
|
||||
auto pBCG = reinterpret_cast<BC4_SNORM*>(pBC+sizeof(BC4_SNORM));
|
||||
float theTexelsU[NUM_PIXELS_PER_BLOCK];
|
||||
float theTexelsV[NUM_PIXELS_PER_BLOCK];
|
||||
|
||||
|
@ -3266,7 +3266,7 @@ HRESULT Convert( const Image& srcImage, DXGI_FORMAT format, DWORD filter, float
|
||||
|| IsTypeless(srcImage.format) || IsTypeless(format) )
|
||||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( (srcImage.width > 0xFFFFFFFF) || (srcImage.height > 0xFFFFFFFF) )
|
||||
return E_INVALIDARG;
|
||||
#endif
|
||||
@ -3317,7 +3317,7 @@ HRESULT Convert( const Image* srcImages, size_t nimages, const TexMetadata& meta
|
||||
|| IsTypeless(metadata.format) || IsTypeless(format) )
|
||||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( (metadata.width > 0xFFFFFFFF) || (metadata.height > 0xFFFFFFFF) )
|
||||
return E_INVALIDARG;
|
||||
#endif
|
||||
@ -3357,7 +3357,7 @@ HRESULT Convert( const Image* srcImages, size_t nimages, const TexMetadata& meta
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( (src.width > 0xFFFFFFFF) || (src.height > 0xFFFFFFFF) )
|
||||
return E_FAIL;
|
||||
#endif
|
||||
@ -3406,7 +3406,7 @@ HRESULT Convert( const Image* srcImages, size_t nimages, const TexMetadata& meta
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( (src.width > 0xFFFFFFFF) || (src.height > 0xFFFFFFFF) )
|
||||
return E_FAIL;
|
||||
#endif
|
||||
|
@ -43,7 +43,7 @@ static HRESULT _Capture( _In_ ID3D11DeviceContext* pContext, _In_ ID3D11Resource
|
||||
if ( FAILED(hr) )
|
||||
return hr;
|
||||
|
||||
const uint8_t* pslice = reinterpret_cast<const uint8_t*>( mapped.pData );
|
||||
auto pslice = reinterpret_cast<const uint8_t*>( mapped.pData );
|
||||
if ( !pslice )
|
||||
{
|
||||
pContext->Unmap( pSource, dindex );
|
||||
@ -121,7 +121,7 @@ static HRESULT _Capture( _In_ ID3D11DeviceContext* pContext, _In_ ID3D11Resource
|
||||
|
||||
size_t lines = ComputeScanlines( metadata.format, height );
|
||||
|
||||
const uint8_t* sptr = reinterpret_cast<const uint8_t*>( mapped.pData );
|
||||
auto sptr = reinterpret_cast<const uint8_t*>( mapped.pData );
|
||||
uint8_t* dptr = img->pixels;
|
||||
for( size_t h = 0; h < lines; ++h )
|
||||
{
|
||||
@ -361,7 +361,7 @@ HRESULT CreateTextureEx( ID3D11Device* pDevice, const Image* srcImages, size_t n
|
||||
if ( !metadata.mipLevels || !metadata.arraySize )
|
||||
return E_INVALIDARG;
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( (metadata.width > 0xFFFFFFFF) || (metadata.height > 0xFFFFFFFF)
|
||||
|| (metadata.mipLevels > 0xFFFFFFFF) || (metadata.arraySize > 0xFFFFFFFF) )
|
||||
return E_INVALIDARG;
|
||||
@ -378,7 +378,7 @@ HRESULT CreateTextureEx( ID3D11Device* pDevice, const Image* srcImages, size_t n
|
||||
if ( !metadata.depth )
|
||||
return E_INVALIDARG;
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( metadata.depth > 0xFFFFFFFF )
|
||||
return E_INVALIDARG;
|
||||
#endif
|
||||
|
@ -225,8 +225,7 @@ static HRESULT _DecodeDDSHeader( _In_reads_bytes_(size) LPCVOID pSource, size_t
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
const DDS_HEADER* pHeader = reinterpret_cast<const DDS_HEADER*>( (const uint8_t*)pSource + sizeof( uint32_t ) );
|
||||
assert( pHeader );
|
||||
auto pHeader = reinterpret_cast<const DDS_HEADER*>( (const uint8_t*)pSource + sizeof( uint32_t ) );
|
||||
|
||||
// Verify header to validate DDS file
|
||||
if ( pHeader->dwSize != sizeof(DDS_HEADER)
|
||||
@ -244,12 +243,12 @@ static HRESULT _DecodeDDSHeader( _In_reads_bytes_(size) LPCVOID pSource, size_t
|
||||
&& (MAKEFOURCC( 'D', 'X', '1', '0' ) == pHeader->ddspf.dwFourCC) )
|
||||
{
|
||||
// Buffer must be big enough for both headers and magic value
|
||||
if ( size < (sizeof(DDS_HEADER)+sizeof(uint32_t)+sizeof(DDS_HEADER_DXT10)) )
|
||||
if ( size < ( sizeof(DDS_HEADER) + sizeof(uint32_t) + sizeof(DDS_HEADER_DXT10) ) )
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
const DDS_HEADER_DXT10* d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>( (const uint8_t*)pSource + sizeof( uint32_t ) + sizeof(DDS_HEADER) );
|
||||
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>( (const uint8_t*)pSource + sizeof( uint32_t ) + sizeof(DDS_HEADER) );
|
||||
convFlags |= CONV_FLAGS_DX10;
|
||||
|
||||
metadata.arraySize = d3d10ext->arraySize;
|
||||
@ -538,7 +537,7 @@ HRESULT _EncodeDDSHeader( const TexMetadata& metadata, DWORD flags,
|
||||
|
||||
*reinterpret_cast<uint32_t*>(pDestination) = DDS_MAGIC;
|
||||
|
||||
DDS_HEADER* header = reinterpret_cast<DDS_HEADER*>( reinterpret_cast<uint8_t*>(pDestination) + sizeof(uint32_t) );
|
||||
auto header = reinterpret_cast<DDS_HEADER*>( reinterpret_cast<uint8_t*>(pDestination) + sizeof(uint32_t) );
|
||||
assert( header );
|
||||
|
||||
memset( header, 0, sizeof(DDS_HEADER ) );
|
||||
@ -550,7 +549,7 @@ HRESULT _EncodeDDSHeader( const TexMetadata& metadata, DWORD flags,
|
||||
{
|
||||
header->dwFlags |= DDS_HEADER_FLAGS_MIPMAP;
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( metadata.mipLevels > 0xFFFFFFFF )
|
||||
return E_INVALIDARG;
|
||||
#endif
|
||||
@ -564,7 +563,7 @@ HRESULT _EncodeDDSHeader( const TexMetadata& metadata, DWORD flags,
|
||||
switch( metadata.dimension )
|
||||
{
|
||||
case TEX_DIMENSION_TEXTURE1D:
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( metadata.width > 0xFFFFFFFF )
|
||||
return E_INVALIDARG;
|
||||
#endif
|
||||
@ -574,7 +573,7 @@ HRESULT _EncodeDDSHeader( const TexMetadata& metadata, DWORD flags,
|
||||
break;
|
||||
|
||||
case TEX_DIMENSION_TEXTURE2D:
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( metadata.height > 0xFFFFFFFF
|
||||
|| metadata.width > 0xFFFFFFFF)
|
||||
return E_INVALIDARG;
|
||||
@ -592,7 +591,7 @@ HRESULT _EncodeDDSHeader( const TexMetadata& metadata, DWORD flags,
|
||||
break;
|
||||
|
||||
case TEX_DIMENSION_TEXTURE3D:
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( metadata.height > 0xFFFFFFFF
|
||||
|| metadata.width > 0xFFFFFFFF
|
||||
|| metadata.depth > 0xFFFFFFFF )
|
||||
@ -613,7 +612,7 @@ HRESULT _EncodeDDSHeader( const TexMetadata& metadata, DWORD flags,
|
||||
size_t rowPitch, slicePitch;
|
||||
ComputePitch( metadata.format, metadata.width, metadata.height, rowPitch, slicePitch, CP_FLAGS_NONE );
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( slicePitch > 0xFFFFFFFF
|
||||
|| rowPitch > 0xFFFFFFFF )
|
||||
return E_FAIL;
|
||||
@ -634,14 +633,14 @@ HRESULT _EncodeDDSHeader( const TexMetadata& metadata, DWORD flags,
|
||||
{
|
||||
memcpy_s( &header->ddspf, sizeof(header->ddspf), &DDSPF_DX10, sizeof(DDS_PIXELFORMAT) );
|
||||
|
||||
DDS_HEADER_DXT10* ext = reinterpret_cast<DDS_HEADER_DXT10*>( reinterpret_cast<uint8_t*>(header) + sizeof(DDS_HEADER) );
|
||||
auto ext = reinterpret_cast<DDS_HEADER_DXT10*>( reinterpret_cast<uint8_t*>(header) + sizeof(DDS_HEADER) );
|
||||
assert( ext );
|
||||
|
||||
memset( ext, 0, sizeof(DDS_HEADER_DXT10) );
|
||||
ext->dxgiFormat = metadata.format;
|
||||
ext->resourceDimension = metadata.dimension;
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( metadata.arraySize > 0xFFFFFFFF )
|
||||
return E_INVALIDARG;
|
||||
#endif
|
||||
@ -1390,7 +1389,7 @@ HRESULT LoadFromDDSMemory( LPCVOID pSource, size_t size, DWORD flags, TexMetadat
|
||||
if ( FAILED(hr) )
|
||||
return hr;
|
||||
|
||||
LPCVOID pPixels = reinterpret_cast<LPCVOID>( reinterpret_cast<const uint8_t*>(pSource) + offset );
|
||||
auto pPixels = reinterpret_cast<LPCVOID>( reinterpret_cast<const uint8_t*>(pSource) + offset );
|
||||
assert( pPixels );
|
||||
hr = _CopyImage( pPixels, size - offset, mdata,
|
||||
(flags & DDS_FLAGS_LEGACY_DWORD) ? CP_FLAGS_LEGACY_DWORD : CP_FLAGS_NONE, convFlags, pal8, image );
|
||||
@ -1611,7 +1610,7 @@ HRESULT SaveToDDSMemory( const Image* images, size_t nimages, const TexMetadata&
|
||||
if ( FAILED(hr) )
|
||||
return hr;
|
||||
|
||||
uint8_t* pDestination = reinterpret_cast<uint8_t*>( blob.GetBufferPointer() );
|
||||
auto pDestination = reinterpret_cast<uint8_t*>( blob.GetBufferPointer() );
|
||||
assert( pDestination );
|
||||
|
||||
hr = _EncodeDDSHeader( metadata, flags, pDestination, blob.GetBufferSize(), required );
|
||||
|
@ -135,7 +135,7 @@ HRESULT FlipRotate( const Image& srcImage, DWORD flags, ScratchImage& image )
|
||||
if ( !flags )
|
||||
return E_INVALIDARG;
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( (srcImage.width > 0xFFFFFFFF) || (srcImage.height > 0xFFFFFFFF) )
|
||||
return E_INVALIDARG;
|
||||
#endif
|
||||
@ -280,7 +280,7 @@ HRESULT FlipRotate( const Image* srcImages, size_t nimages, const TexMetadata& m
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( (src.width > 0xFFFFFFFF) || (src.height > 0xFFFFFFFF) )
|
||||
return E_FAIL;
|
||||
#endif
|
||||
|
@ -457,7 +457,7 @@ HRESULT ScratchImage::InitializeFromImage( const Image& srcImage, bool allow1D )
|
||||
if ( !sptr )
|
||||
return E_POINTER;
|
||||
|
||||
uint8_t* dptr = reinterpret_cast<uint8_t*>( _image[0].pixels );
|
||||
auto dptr = reinterpret_cast<uint8_t*>( _image[0].pixels );
|
||||
if ( !dptr )
|
||||
return E_POINTER;
|
||||
|
||||
@ -502,12 +502,12 @@ HRESULT ScratchImage::InitializeArrayFromImages( const Image* images, size_t nIm
|
||||
|
||||
for( size_t index=0; index < nImages; ++index )
|
||||
{
|
||||
const uint8_t* sptr = reinterpret_cast<const uint8_t*>( images[index].pixels );
|
||||
auto sptr = reinterpret_cast<const uint8_t*>( images[index].pixels );
|
||||
if ( !sptr )
|
||||
return E_POINTER;
|
||||
|
||||
assert( index < _nimages );
|
||||
uint8_t* dptr = reinterpret_cast<uint8_t*>( _image[index].pixels );
|
||||
auto dptr = reinterpret_cast<uint8_t*>( _image[index].pixels );
|
||||
if ( !dptr )
|
||||
return E_POINTER;
|
||||
|
||||
@ -569,12 +569,12 @@ HRESULT ScratchImage::Initialize3DFromImages( const Image* images, size_t depth
|
||||
|
||||
for( size_t slice=0; slice < depth; ++slice )
|
||||
{
|
||||
const uint8_t* sptr = reinterpret_cast<const uint8_t*>( images[slice].pixels );
|
||||
auto sptr = reinterpret_cast<const uint8_t*>( images[slice].pixels );
|
||||
if ( !sptr )
|
||||
return E_POINTER;
|
||||
|
||||
assert( slice < _nimages );
|
||||
uint8_t* dptr = reinterpret_cast<uint8_t*>( _image[slice].pixels );
|
||||
auto dptr = reinterpret_cast<uint8_t*>( _image[slice].pixels );
|
||||
if ( !dptr )
|
||||
return E_POINTER;
|
||||
|
||||
|
@ -76,7 +76,7 @@ HRESULT PremultiplyAlpha( const Image& srcImage, ScratchImage& image )
|
||||
|| !HasAlpha(srcImage.format) )
|
||||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( (srcImage.width > 0xFFFFFFFF) || (srcImage.height > 0xFFFFFFFF) )
|
||||
return E_INVALIDARG;
|
||||
#endif
|
||||
@ -118,7 +118,7 @@ HRESULT PremultiplyAlpha( const Image* srcImages, size_t nimages, const TexMetad
|
||||
|| !HasAlpha(metadata.format) )
|
||||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( (metadata.width > 0xFFFFFFFF) || (metadata.height > 0xFFFFFFFF) )
|
||||
return E_INVALIDARG;
|
||||
#endif
|
||||
@ -157,7 +157,7 @@ HRESULT PremultiplyAlpha( const Image* srcImages, size_t nimages, const TexMetad
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( (src.width > 0xFFFFFFFF) || (src.height > 0xFFFFFFFF) )
|
||||
return E_FAIL;
|
||||
#endif
|
||||
|
@ -814,7 +814,7 @@ HRESULT Resize( const Image& srcImage, size_t width, size_t height, DWORD filter
|
||||
if ( width == 0 || height == 0 )
|
||||
return E_INVALIDARG;
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( (srcImage.width > 0xFFFFFFFF) || (srcImage.height > 0xFFFFFFFF) )
|
||||
return E_INVALIDARG;
|
||||
|
||||
@ -878,7 +878,7 @@ HRESULT Resize( const Image* srcImages, size_t nimages, const TexMetadata& metad
|
||||
if ( !srcImages || !nimages || width == 0 || height == 0 )
|
||||
return E_INVALIDARG;
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( (width > 0xFFFFFFFF) || (height > 0xFFFFFFFF) )
|
||||
return E_INVALIDARG;
|
||||
#endif
|
||||
@ -925,7 +925,7 @@ HRESULT Resize( const Image* srcImages, size_t nimages, const TexMetadata& metad
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( (srcimg->width > 0xFFFFFFFF) || (srcimg->height > 0xFFFFFFFF) )
|
||||
{
|
||||
result.Release();
|
||||
@ -986,7 +986,7 @@ HRESULT Resize( const Image* srcImages, size_t nimages, const TexMetadata& metad
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( (srcimg->width > 0xFFFFFFFF) || (srcimg->height > 0xFFFFFFFF) )
|
||||
{
|
||||
result.Release();
|
||||
|
@ -129,8 +129,7 @@ static HRESULT _DecodeTGAHeader( _In_reads_bytes_(size) LPCVOID pSource, size_t
|
||||
return HRESULT_FROM_WIN32( ERROR_INVALID_DATA );
|
||||
}
|
||||
|
||||
const TGA_HEADER* pHeader = reinterpret_cast<const TGA_HEADER*>( pSource );
|
||||
assert( pHeader );
|
||||
auto pHeader = reinterpret_cast<const TGA_HEADER*>( pSource );
|
||||
|
||||
if ( pHeader->bColorMapType != 0
|
||||
|| pHeader->wColorMapLength != 0 )
|
||||
@ -236,7 +235,7 @@ static HRESULT _SetAlphaChannelToOpaque( _In_ const Image* image )
|
||||
{
|
||||
assert( image );
|
||||
|
||||
uint8_t* pPixels = reinterpret_cast<uint8_t*>( image->pixels );
|
||||
auto pPixels = reinterpret_cast<uint8_t*>( image->pixels );
|
||||
if ( !pPixels )
|
||||
return E_POINTER;
|
||||
|
||||
@ -272,7 +271,7 @@ static HRESULT _UncompressPixels( _In_reads_bytes_(size) LPCVOID pSource, size_t
|
||||
ComputePitch( image->format, image->width, image->height, rowPitch, slicePitch, CP_FLAGS_NONE );
|
||||
}
|
||||
|
||||
const uint8_t* sPtr = reinterpret_cast<const uint8_t*>( pSource );
|
||||
auto sPtr = reinterpret_cast<const uint8_t*>( pSource );
|
||||
const uint8_t* endPtr = sPtr + size;
|
||||
|
||||
switch( image->format )
|
||||
@ -926,8 +925,7 @@ HRESULT LoadFromTGAMemory( LPCVOID pSource, size_t size, TexMetadata* metadata,
|
||||
if ( offset > size )
|
||||
return E_FAIL;
|
||||
|
||||
LPCVOID pPixels = reinterpret_cast<LPCVOID>( reinterpret_cast<const uint8_t*>(pSource) + offset );
|
||||
assert( pPixels );
|
||||
auto pPixels = reinterpret_cast<LPCVOID>( reinterpret_cast<const uint8_t*>(pSource) + offset );
|
||||
|
||||
size_t remaining = size - offset;
|
||||
if ( remaining == 0 )
|
||||
@ -1242,12 +1240,12 @@ HRESULT SaveToTGAMemory( const Image& image, Blob& blob )
|
||||
return hr;
|
||||
|
||||
// Copy header
|
||||
uint8_t* dPtr = reinterpret_cast<uint8_t*>( blob.GetBufferPointer() );
|
||||
auto dPtr = reinterpret_cast<uint8_t*>( blob.GetBufferPointer() );
|
||||
assert( dPtr != 0 );
|
||||
memcpy_s( dPtr, blob.GetBufferSize(), &tga_header, sizeof(TGA_HEADER) );
|
||||
dPtr += sizeof(TGA_HEADER);
|
||||
|
||||
const uint8_t* pPixels = reinterpret_cast<const uint8_t*>( image.pixels );
|
||||
auto pPixels = reinterpret_cast<const uint8_t*>( image.pixels );
|
||||
assert( pPixels );
|
||||
|
||||
for( size_t y = 0; y < image.height; ++y )
|
||||
@ -1356,7 +1354,7 @@ HRESULT SaveToTGAFile( const Image& image, LPCWSTR szFile )
|
||||
return E_FAIL;
|
||||
|
||||
// Write pixels
|
||||
const uint8_t* pPixels = reinterpret_cast<const uint8_t*>( image.pixels );
|
||||
auto pPixels = reinterpret_cast<const uint8_t*>( image.pixels );
|
||||
|
||||
for( size_t y = 0; y < image.height; ++y )
|
||||
{
|
||||
|
@ -500,7 +500,7 @@ static HRESULT _EncodeImage( _In_ const Image& image, _In_ DWORD flags, _In_ REF
|
||||
if ( FAILED(hr) )
|
||||
return hr;
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( (image.width > 0xFFFFFFFF) || (image.height > 0xFFFFFFFF) )
|
||||
return E_INVALIDARG;
|
||||
#endif
|
||||
@ -699,7 +699,7 @@ HRESULT GetMetadataFromWICMemory( LPCVOID pSource, size_t size, DWORD flags, Tex
|
||||
if ( !pSource || size == 0 )
|
||||
return E_INVALIDARG;
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( size > 0xFFFFFFFF )
|
||||
return HRESULT_FROM_WIN32( ERROR_FILE_TOO_LARGE );
|
||||
#endif
|
||||
@ -781,7 +781,7 @@ HRESULT LoadFromWICMemory( LPCVOID pSource, size_t size, DWORD flags, TexMetadat
|
||||
if ( !pSource || size == 0 )
|
||||
return E_INVALIDARG;
|
||||
|
||||
#ifdef _AMD64_
|
||||
#ifdef _M_X64
|
||||
if ( size > 0xFFFFFFFF )
|
||||
return HRESULT_FROM_WIN32( ERROR_FILE_TOO_LARGE );
|
||||
#endif
|
||||
|
@ -712,7 +712,7 @@ HRESULT DirectX::SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
||||
|
||||
*reinterpret_cast<uint32_t*>(&fileHeader[0]) = DDS_MAGIC;
|
||||
|
||||
DDS_HEADER* header = reinterpret_cast<DDS_HEADER*>( reinterpret_cast<uint8_t*>(&fileHeader[0]) + sizeof(uint32_t) );
|
||||
auto header = reinterpret_cast<DDS_HEADER*>( reinterpret_cast<uint8_t*>(&fileHeader[0]) + sizeof(uint32_t) );
|
||||
size_t headerSize = sizeof(uint32_t) + sizeof(DDS_HEADER);
|
||||
memset( header, 0, sizeof(DDS_HEADER) );
|
||||
header->size = sizeof( DDS_HEADER );
|
||||
@ -796,7 +796,7 @@ HRESULT DirectX::SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext,
|
||||
if ( FAILED(hr) )
|
||||
return hr;
|
||||
|
||||
const uint8_t* sptr = reinterpret_cast<const uint8_t*>( mapped.pData );
|
||||
auto sptr = reinterpret_cast<const uint8_t*>( mapped.pData );
|
||||
if ( !sptr )
|
||||
{
|
||||
pContext->Unmap( pStaging.Get(), 0 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user