mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:37:44 +00:00
LibGfx/DDS: Move the code to read the header in its own function
This commit is contained in:
parent
76efdaeecd
commit
742897519d
1 changed files with 8 additions and 1 deletions
|
@ -410,7 +410,7 @@ static ErrorOr<void> decode_bitmap(Stream& stream, DDSLoadingContext& context, u
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
static ErrorOr<void> decode_dds(DDSLoadingContext& context)
|
static ErrorOr<void> decode_header(DDSLoadingContext& context)
|
||||||
{
|
{
|
||||||
// All valid DDS files are at least 128 bytes long.
|
// All valid DDS files are at least 128 bytes long.
|
||||||
if (TRY(context.stream.size()) < 128) {
|
if (TRY(context.stream.size()) < 128) {
|
||||||
|
@ -465,6 +465,13 @@ static ErrorOr<void> decode_dds(DDSLoadingContext& context)
|
||||||
return Error::from_string_literal("Format type is not supported at the moment");
|
return Error::from_string_literal("Format type is not supported at the moment");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
static ErrorOr<void> decode_dds(DDSLoadingContext& context)
|
||||||
|
{
|
||||||
|
TRY(decode_header(context));
|
||||||
|
|
||||||
// We support parsing mipmaps, but we only care about the largest one :^) (At least for now)
|
// We support parsing mipmaps, but we only care about the largest one :^) (At least for now)
|
||||||
if (size_t mipmap_level = 0; mipmap_level < max(context.header.mip_map_count, 1u)) {
|
if (size_t mipmap_level = 0; mipmap_level < max(context.header.mip_map_count, 1u)) {
|
||||||
u64 width = get_width(context.header, mipmap_level);
|
u64 width = get_width(context.header, mipmap_level);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue