Browse Source

Remove unused variables

pull/3096/head
Brian Popow 2 months ago
parent
commit
fccd5b55d9
  1. 40
      src/ImageSharp/Formats/Exr/ExrDecoderCore.cs
  2. 3
      src/ImageSharp/Formats/Exr/ExrEncoderCore.cs

40
src/ImageSharp/Formats/Exr/ExrDecoderCore.cs

@ -371,30 +371,9 @@ internal sealed class ExrDecoderCore : ImageDecoderCore
{
ExrHeaderAttributes header = this.ReadExrHeader(stream);
int bitsPerPixel = this.CalculateBitsPerPixel();
return new ImageInfo(new Size(header.DataWindow.XMax, header.DataWindow.YMax), this.metadata);
}
private int CalculateBitsPerPixel()
{
int bitsPerPixel = 0;
for (int i = 0; i < this.Channels.Count; i++)
{
ExrChannelInfo channel = this.Channels[0];
if (channel.PixelType is ExrPixelType.Float or ExrPixelType.UnsignedInt)
{
bitsPerPixel += 32;
}
else if (channel.PixelType == ExrPixelType.Half)
{
bitsPerPixel += 16;
}
}
return bitsPerPixel;
}
private ExrPixelType ValidateChannels()
{
if (this.Channels.Count == 0)
@ -475,8 +454,8 @@ internal sealed class ExrDecoderCore : ImageDecoderCore
// Next three bytes contain info's about the image.
byte flagsByte0 = (byte)stream.ReadByte();
byte flagsByte1 = (byte)stream.ReadByte();
byte flagsByte2 = (byte)stream.ReadByte();
stream.ReadByte();
stream.ReadByte();
if ((flagsByte0 & (1 << 1)) != 0)
{
ExrThrowHelper.ThrowNotSupported("Decoding tiled exr images is not supported yet!");
@ -587,6 +566,11 @@ internal sealed class ExrDecoderCore : ImageDecoderCore
ExrThrowHelper.ThrowInvalidImageContentException("Invalid exr image header, the lineOrder attribute is missing!");
}
if (!aspectRatio.HasValue)
{
ExrThrowHelper.ThrowInvalidImageContentException("Invalid exr image header, the aspectRatio attribute is missing!");
}
if (!screenWindowWidth.HasValue)
{
ExrThrowHelper.ThrowInvalidImageContentException("Invalid exr image header, the screenWindowWidth attribute is missing!");
@ -648,7 +632,7 @@ internal sealed class ExrDecoderCore : ImageDecoderCore
}
// Last byte should be a null byte.
int byteRead = stream.ReadByte();
stream.ReadByte();
return channels;
}
@ -662,9 +646,11 @@ internal sealed class ExrDecoderCore : ImageDecoderCore
bytesRead += 4;
byte pLinear = (byte)stream.ReadByte();
byte reserved0 = (byte)stream.ReadByte();
byte reserved1 = (byte)stream.ReadByte();
byte reserved2 = (byte)stream.ReadByte();
// Next 3 bytes are reserved bytes and not use.
stream.ReadByte();
stream.ReadByte();
stream.ReadByte();
bytesRead += 4;
int xSampling = this.ReadSignedInteger(stream);

3
src/ImageSharp/Formats/Exr/ExrEncoderCore.cs

@ -122,8 +122,6 @@ internal sealed class ExrEncoderCore
// Next is offsets table to each pixel row, which will be written after the pixel data was written.
int bytesPerChannel = this.pixelType == ExrPixelType.Half ? 2 : 4;
int numberOfChannels = 3;
uint rowSizeBytes = (uint)(width * numberOfChannels * bytesPerChannel);
ulong startOfRowOffsetData = (ulong)stream.Position;
stream.Position += 8 * height;
@ -162,7 +160,6 @@ internal sealed class ExrEncoderCore
uint bytesPerRow = ExrUtils.CalculateBytesPerRow(channels, (uint)width);
uint rowsPerBlock = ExrUtils.RowsPerBlock(compression);
uint bytesPerBlock = bytesPerRow * rowsPerBlock;
int channelCount = channels.Count;
using IMemoryOwner<float> rgbBuffer = this.memoryAllocator.Allocate<float>(width * 3, AllocationOptions.Clean);
using IMemoryOwner<byte> rowBlockBuffer = this.memoryAllocator.Allocate<byte>((int)bytesPerBlock, AllocationOptions.Clean);

Loading…
Cancel
Save