Browse Source

Simplify ReadBgra32

pull/1574/head
Brian Popow 6 years ago
parent
commit
b89c099e71
  1. 20
      src/ImageSharp/Formats/Tga/TgaDecoderCore.cs

20
src/ImageSharp/Formats/Tga/TgaDecoderCore.cs

@ -532,26 +532,8 @@ namespace SixLabors.ImageSharp.Formats.Tga
{
TPixel color = default;
bool isXInverted = origin == TgaImageOrigin.BottomRight || origin == TgaImageOrigin.TopRight;
if (this.tgaMetadata.AlphaChannelBits == 8)
if (this.tgaMetadata.AlphaChannelBits == 8 && !isXInverted)
{
if (isXInverted)
{
for (int y = 0; y < height; y++)
{
int newY = InvertY(y, height, origin);
Span<TPixel> pixelSpan = pixels.GetRowSpan(newY);
for (int x = 0; x < width; x++)
{
this.currentStream.Read(this.scratchBuffer, 0, 4);
color.FromBgra32(Unsafe.As<byte, Bgra32>(ref this.scratchBuffer[0]));
int newX = InvertX(x, width, origin);
pixelSpan[newX] = color;
}
}
return;
}
using (IManagedByteBuffer row = this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, 4, 0))
{
for (int y = 0; y < height; y++)

Loading…
Cancel
Save