|
|
@ -307,8 +307,7 @@ internal sealed class TgaDecoderCore : IImageDecoderInternals |
|
|
private void ReadPalettedRle<TPixel>(BufferedReadStream stream, int width, int height, Buffer2D<TPixel> pixels, Span<byte> palette, int colorMapPixelSizeInBytes, TgaImageOrigin origin) |
|
|
private void ReadPalettedRle<TPixel>(BufferedReadStream stream, int width, int height, Buffer2D<TPixel> pixels, Span<byte> palette, int colorMapPixelSizeInBytes, TgaImageOrigin origin) |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
using (IMemoryOwner<byte> buffer = this.memoryAllocator.Allocate<byte>(width * height, AllocationOptions.Clean)) |
|
|
using IMemoryOwner<byte> buffer = this.memoryAllocator.Allocate<byte>(width * height, AllocationOptions.Clean); |
|
|
{ |
|
|
|
|
|
TPixel color = default; |
|
|
TPixel color = default; |
|
|
Span<byte> bufferSpan = buffer.GetSpan(); |
|
|
Span<byte> bufferSpan = buffer.GetSpan(); |
|
|
this.UncompressRle(stream, width, height, bufferSpan, bytesPerPixel: 1); |
|
|
this.UncompressRle(stream, width, height, bufferSpan, bytesPerPixel: 1); |
|
|
@ -342,7 +341,6 @@ internal sealed class TgaDecoderCore : IImageDecoderInternals |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Reads a uncompressed monochrome TGA image.
|
|
|
/// Reads a uncompressed monochrome TGA image.
|
|
|
@ -598,8 +596,7 @@ internal sealed class TgaDecoderCore : IImageDecoderInternals |
|
|
Guard.NotNull(this.tgaMetadata); |
|
|
Guard.NotNull(this.tgaMetadata); |
|
|
|
|
|
|
|
|
byte alphaBits = this.tgaMetadata.AlphaChannelBits; |
|
|
byte alphaBits = this.tgaMetadata.AlphaChannelBits; |
|
|
using (IMemoryOwner<byte> buffer = this.memoryAllocator.Allocate<byte>(width * height * bytesPerPixel, AllocationOptions.Clean)) |
|
|
using IMemoryOwner<byte> buffer = this.memoryAllocator.Allocate<byte>(width * height * bytesPerPixel, AllocationOptions.Clean); |
|
|
{ |
|
|
|
|
|
Span<byte> bufferSpan = buffer.GetSpan(); |
|
|
Span<byte> bufferSpan = buffer.GetSpan(); |
|
|
this.UncompressRle(stream, width, height, bufferSpan, bytesPerPixel); |
|
|
this.UncompressRle(stream, width, height, bufferSpan, bytesPerPixel); |
|
|
for (int y = 0; y < height; y++) |
|
|
for (int y = 0; y < height; y++) |
|
|
@ -654,7 +651,6 @@ internal sealed class TgaDecoderCore : IImageDecoderInternals |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
/// <inheritdoc />
|
|
|
public ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) |
|
|
public ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) |
|
|
@ -952,7 +948,6 @@ internal sealed class TgaDecoderCore : IImageDecoderInternals |
|
|
this.hasAlpha = alphaBits > 0; |
|
|
this.hasAlpha = alphaBits > 0; |
|
|
|
|
|
|
|
|
// Bits 4 and 5 describe the image origin.
|
|
|
// Bits 4 and 5 describe the image origin.
|
|
|
TgaImageOrigin origin = (TgaImageOrigin)((this.fileHeader.ImageDescriptor & 0x30) >> 4); |
|
|
return (TgaImageOrigin)((this.fileHeader.ImageDescriptor & 0x30) >> 4); |
|
|
return origin; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|