|
|
|
@ -1,7 +1,9 @@ |
|
|
|
// Copyright (c) Six Labors and contributors.
|
|
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System.IO; |
|
|
|
using SixLabors.ImageSharp.Memory; |
|
|
|
using SixLabors.ImageSharp.PixelFormats; |
|
|
|
|
|
|
|
namespace SixLabors.ImageSharp.Formats.Tga |
|
|
|
@ -17,7 +19,20 @@ namespace SixLabors.ImageSharp.Formats.Tga |
|
|
|
{ |
|
|
|
Guard.NotNull(stream, nameof(stream)); |
|
|
|
|
|
|
|
return new TgaDecoderCore(configuration, this).Decode<TPixel>(stream); |
|
|
|
var decoder = new TgaDecoderCore(configuration, this); |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
return decoder.Decode<TPixel>(stream); |
|
|
|
} |
|
|
|
catch (InvalidMemoryOperationException ex) |
|
|
|
{ |
|
|
|
Size dims = decoder.Dimensions; |
|
|
|
|
|
|
|
// TODO: use InvalidImageContentException here, if we decide to define it
|
|
|
|
// https://github.com/SixLabors/ImageSharp/issues/1110
|
|
|
|
throw new ImageFormatException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}.", ex); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|