Skip to content

Commit 94d0f72

Browse files
committed
Small fixes and variable naming
1 parent 86ff81a commit 94d0f72

File tree

12 files changed

+20
-18
lines changed

12 files changed

+20
-18
lines changed

src/ImageSharp.Textures/Compression/Astc/ColorEncoding/EndpointEncoder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public static bool EncodeColorsForMode(Rgba32 endpointLowRgba, Rgba32 endpointHi
140140
break;
141141
}
142142

143-
case EndpointEncodingMode.DirectRbg:
143+
case EndpointEncodingMode.DirectRgb:
144144
case EndpointEncodingMode.DirectRgba:
145145
return EncodeColorsRGBA(endpointLowRgba, endpointHighRgba, maxValue, encodingMode == EndpointEncodingMode.DirectRgba, out astcMode, values);
146146
default:

src/ImageSharp.Textures/Compression/Astc/ColorEncoding/EndpointEncodingMode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ internal enum EndpointEncodingMode
99
DirectLumaAlpha,
1010
BaseScaleRgb,
1111
BaseScaleRgba,
12-
DirectRbg,
12+
DirectRgb,
1313
DirectRgba
1414
}

src/ImageSharp.Textures/Compression/Astc/ColorEncoding/EndpointEncodingModeExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal static class EndpointEncodingModeExtensions
99
{
1010
EndpointEncodingMode.DirectLuma => 2,
1111
EndpointEncodingMode.DirectLumaAlpha or EndpointEncodingMode.BaseScaleRgb => 4,
12-
EndpointEncodingMode.DirectRbg or EndpointEncodingMode.BaseScaleRgba => 6,
12+
EndpointEncodingMode.DirectRgb or EndpointEncodingMode.BaseScaleRgba => 6,
1313
_ => 8
1414
};
1515
}

src/ImageSharp.Textures/Compression/Astc/IO/AstcFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ public static AstcFile FromMemory(byte[] data)
6464
(10, 10) => Footprint.FromFootprintType(FootprintType.Footprint10x10),
6565
(12, 10) => Footprint.FromFootprintType(FootprintType.Footprint12x10),
6666
(12, 12) => Footprint.FromFootprintType(FootprintType.Footprint12x12),
67-
_ => throw new ArgumentOutOfRangeException($"Unsupported block dimensions: {this.header.BlockWidth}x{this.header.BlockHeight}"),
67+
_ => throw new NotSupportedException($"Unsupported block dimensions: {this.header.BlockWidth}x{this.header.BlockHeight}"),
6868
};
6969
}

src/ImageSharp.Textures/Formats/Ktx/KtxProcessor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public MipMap[] DecodeMipMaps(Stream stream, int width, int height, uint count)
128128
return this.AllocateMipMaps<RgbaAstc8X8>(stream, width, height, count);
129129
case GlInternalPixelFormat.CompressedRgbaAstc10x5Khr:
130130
case GlInternalPixelFormat.CompressedSrgb8Alpha8Astc10x5Khr:
131-
return this.AllocateMipMaps<RgbaAstc10x5>(stream, width, height, count);
131+
return this.AllocateMipMaps<RgbaAstc10X5>(stream, width, height, count);
132132
case GlInternalPixelFormat.CompressedRgbaAstc10x6Khr:
133133
case GlInternalPixelFormat.CompressedSrgb8Alpha8Astc10x6Khr:
134134
return this.AllocateMipMaps<RgbaAstc10X6>(stream, width, height, count);
@@ -267,7 +267,7 @@ public CubemapTexture DecodeCubeMap(Stream stream, int width, int height)
267267
return this.AllocateCubeMap<RgbaAstc8X8>(stream, width, height);
268268
case GlInternalPixelFormat.CompressedRgbaAstc10x5Khr:
269269
case GlInternalPixelFormat.CompressedSrgb8Alpha8Astc10x5Khr:
270-
return this.AllocateCubeMap<RgbaAstc10x5>(stream, width, height);
270+
return this.AllocateCubeMap<RgbaAstc10X5>(stream, width, height);
271271
case GlInternalPixelFormat.CompressedRgbaAstc10x6Khr:
272272
case GlInternalPixelFormat.CompressedSrgb8Alpha8Astc10x6Khr:
273273
return this.AllocateCubeMap<RgbaAstc10X6>(stream, width, height);

src/ImageSharp.Textures/Formats/Ktx2/Ktx2DecoderCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public Texture DecodeTexture(Stream stream)
113113
}
114114
}
115115

116-
if (stream.Position < maxEndPosition && stream.CanSeek)
116+
if (stream.CanSeek && stream.Position < maxEndPosition)
117117
{
118118
stream.Position = maxEndPosition;
119119
}

src/ImageSharp.Textures/Formats/Ktx2/Ktx2Processor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public MipMap[] DecodeMipMaps(Stream stream, int width, int height, LevelIndex[]
189189
return AllocateMipMaps<RgbaAstc8X8>(memoryStream, width, height, levelIndices);
190190
case VkFormat.VK_FORMAT_ASTC_10x5_UNORM_BLOCK:
191191
case VkFormat.VK_FORMAT_ASTC_10x5_SRGB_BLOCK:
192-
return AllocateMipMaps<RgbaAstc10x5>(memoryStream, width, height, levelIndices);
192+
return AllocateMipMaps<RgbaAstc10X5>(memoryStream, width, height, levelIndices);
193193
case VkFormat.VK_FORMAT_ASTC_10x6_UNORM_BLOCK:
194194
case VkFormat.VK_FORMAT_ASTC_10x6_SRGB_BLOCK:
195195
return AllocateMipMaps<RgbaAstc10X6>(memoryStream, width, height, levelIndices);
@@ -364,7 +364,7 @@ public CubemapTexture DecodeCubeMap(Stream stream, int width, int height, LevelI
364364
return AllocateCubeMap<RgbaAstc8X8>(stream, width, height, levelIndices);
365365
case VkFormat.VK_FORMAT_ASTC_10x5_UNORM_BLOCK:
366366
case VkFormat.VK_FORMAT_ASTC_10x5_SRGB_BLOCK:
367-
return AllocateCubeMap<RgbaAstc10x5>(stream, width, height, levelIndices);
367+
return AllocateCubeMap<RgbaAstc10X5>(stream, width, height, levelIndices);
368368
case VkFormat.VK_FORMAT_ASTC_10x6_UNORM_BLOCK:
369369
case VkFormat.VK_FORMAT_ASTC_10x6_SRGB_BLOCK:
370370
return AllocateCubeMap<RgbaAstc10X6>(stream, width, height, levelIndices);

src/ImageSharp.Textures/TextureFormats/Decoding/RgbaAstc10x5.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding;
66
/// <summary>
77
/// Texture compressed with RgbaAstc10x5.
88
/// </summary>
9-
internal readonly struct RgbaAstc10x5 : IBlock<RgbaAstc10x5>
9+
internal readonly struct RgbaAstc10X5 : IBlock<RgbaAstc10X5>
1010
{
1111
public static Size BlockSize => new(10, 5);
1212

src/ImageSharp.Textures/TextureFormats/Decoding/RgbaAstc12x12.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding;
1111
public static Size BlockSize => new(12, 12);
1212

1313
/// <inheritdoc/>
14-
public int BitsPerPixel => 128 / (BlockSize.Width * BlockSize.Height);
14+
public int BitsPerPixel => 1; // Actually 0.888... but we round up for simplicity
1515

1616
/// <inheritdoc/>
1717
public byte PixelDepthBytes => 4;

tests/ImageSharp.Textures.Benchmarks/AstcDecodingBenchmark.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public bool ParseBlock()
2929
blocks[..16].CopyTo(blockBytes);
3030
ulong low = BitConverter.ToUInt64(blockBytes);
3131
ulong high = BitConverter.ToUInt64(blockBytes[8..]);
32-
PhysicalBlock phyiscalBlock = PhysicalBlock.Create((UInt128)low | ((UInt128)high << 64));
32+
PhysicalBlock physicalBlock = PhysicalBlock.Create((UInt128)low | ((UInt128)high << 64));
3333

34-
return !phyiscalBlock.IsIllegalEncoding;
34+
return !physicalBlock.IsIllegalEncoding;
3535
}
3636

3737
[Benchmark]

0 commit comments

Comments
 (0)