Skip to content

Commit

Permalink
Update DirectXTexPNG.cpp
Browse files Browse the repository at this point in the history
added error since interlacing fails
  • Loading branch information
walbourn authored Sep 3, 2024
1 parent 4f3623f commit e4aad30
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Auxiliary/DirectXTexPNG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ namespace
void Update() noexcept(false)
{
png_read_info(st, info);
// check for unsupported cases
png_byte interlacing = png_get_interlace_type(st, info);
if (interlacing != PNG_INTERLACE_NONE)
{
throw std::invalid_argument{ "interlacing not supported" };
}
// color handling
png_byte color_type = png_get_color_type(st, info);
if (color_type == PNG_COLOR_TYPE_GRAY)
Expand Down Expand Up @@ -277,7 +283,7 @@ namespace
color_type = PNG_COLOR_TYPE_RGBA;
break;
default:
return E_INVALIDARG;
return HRESULT_E_NOT_SUPPORTED;
}

png_set_IHDR(st, info,
Expand Down Expand Up @@ -334,6 +340,10 @@ HRESULT DirectX::GetMetadataFromPNGFile(
return (ec.code().value() == ENOENT) ? HRESULT_ERROR_FILE_NOT_FOUND : E_FAIL;
#endif
}
catch (const std::invalid_argument&)
{
return HRESULT_E_NOT_SUPPORTED;
}
catch (const std::exception&)
{
return E_FAIL;
Expand Down Expand Up @@ -375,6 +385,10 @@ HRESULT DirectX::LoadFromPNGFile(
return (ec.code().value() == ENOENT) ? HRESULT_ERROR_FILE_NOT_FOUND : E_FAIL;
#endif
}
catch (const std::invalid_argument&)
{
return HRESULT_E_NOT_SUPPORTED;
}
catch (const std::exception&)
{
image.Release();
Expand Down

0 comments on commit e4aad30

Please sign in to comment.