Skip to content

Commit

Permalink
update package info, add net 5 target, and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
ds5678 committed Feb 12, 2022
1 parent b0038a5 commit cab5cab
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 25 deletions.
2 changes: 1 addition & 1 deletion AstcTest/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Drawing.Imaging;
using System.IO;
using TextureDecoder.Astc;
using AssetRipper.TextureDecoder.Astc;

namespace AstcTest
{
Expand Down
2 changes: 1 addition & 1 deletion AtcTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Diagnostics;
using System.Drawing.Imaging;
using System.IO;
using TextureDecoder.Atc;
using AssetRipper.TextureDecoder.Atc;

namespace AtcTest
{
Expand Down
2 changes: 1 addition & 1 deletion DxtTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Diagnostics;
using System.Drawing.Imaging;
using System.IO;
using TextureDecoder.Dxt;
using AssetRipper.TextureDecoder.Dxt;

namespace DxtTest
{
Expand Down
2 changes: 1 addition & 1 deletion EtcTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Diagnostics;
using System.Drawing.Imaging;
using System.IO;
using TextureDecoder.Etc;
using AssetRipper.TextureDecoder.Etc;

namespace EtcTest
{
Expand Down
2 changes: 1 addition & 1 deletion PvrtcTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Diagnostics;
using System.Drawing.Imaging;
using System.IO;
using TextureDecoder.Pvrtc;
using AssetRipper.TextureDecoder.Pvrtc;

namespace PvrtcTest
{
Expand Down
2 changes: 1 addition & 1 deletion RgbTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Diagnostics;
using System.Drawing.Imaging;
using System.IO;
using TextureDecoder.Rgb;
using AssetRipper.TextureDecoder.Rgb;

namespace RgbTest
{
Expand Down
2 changes: 1 addition & 1 deletion TextureDecoder/Astc/AstcDecoder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Runtime.CompilerServices;

namespace TextureDecoder.Astc
namespace AssetRipper.TextureDecoder.Astc
{
/// <summary>
///
Expand Down
2 changes: 1 addition & 1 deletion TextureDecoder/Atc/AtcDecoder.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Runtime.CompilerServices;

namespace TextureDecoder.Atc
namespace AssetRipper.TextureDecoder.Atc
{
/// <summary>
///
Expand Down
2 changes: 1 addition & 1 deletion TextureDecoder/Dxt/DxtDecoder.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Runtime.CompilerServices;

namespace TextureDecoder.Dxt
namespace AssetRipper.TextureDecoder.Dxt
{
/// <summary>
///
Expand Down
2 changes: 1 addition & 1 deletion TextureDecoder/Etc/EtcDecoder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Runtime.CompilerServices;

namespace TextureDecoder.Etc
namespace AssetRipper.TextureDecoder.Etc
{
/// <summary>
///
Expand Down
2 changes: 1 addition & 1 deletion TextureDecoder/Pvrtc/PvrtcDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Runtime.CompilerServices;

namespace TextureDecoder.Pvrtc
namespace AssetRipper.TextureDecoder.Pvrtc
{
/// <summary>
///
Expand Down
25 changes: 17 additions & 8 deletions TextureDecoder/Rgb/RgbConverter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using System.Runtime.CompilerServices;
#if NET5_0_OR_GREATER
using System.Buffers.Binary;
#endif

namespace TextureDecoder.Rgb
namespace AssetRipper.TextureDecoder.Rgb
{
/// <summary>
///
Expand Down Expand Up @@ -696,21 +699,26 @@ public static void RGB9e5FloatToBGRA32(byte[] input, int width, int height, byte
private static float ToHalf(byte[] input, int offset)
{
#if NET6_0_OR_GREATER
return (float)System.Buffers.Binary.BinaryPrimitives.ReadHalfLittleEndian(input.AsSpan(offset, 2));
#elif NET5_0_OR_GREATER
if(BitConverter.IsLittleEndian)
return (float)BitConverter.ToHalf(input, offset);
else
return (float)BitConverter.ToHalf(new byte[] { input[offset + 1], input[offset] });
return (float)BinaryPrimitives.ReadHalfLittleEndian(input.AsSpan(offset, 2));
#elif NET5_0
return (float)ToHalf(BinaryPrimitives.ReadUInt16LittleEndian(input.AsSpan(offset, 2)));
#else
return (float)Half.ToHalf(input, offset);
#endif
}

#if NET5_0
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static unsafe Half ToHalf(ushort bits)
{
return *((Half*)&bits);
}
#endif

private static float ToSingle(byte[] input, int offset)
{
#if NET5_0_OR_GREATER
return System.Buffers.Binary.BinaryPrimitives.ReadSingleLittleEndian(input.AsSpan(offset, 4));
return BinaryPrimitives.ReadSingleLittleEndian(input.AsSpan(offset, 4));
#else
if (BitConverter.IsLittleEndian)
return BitConverter.ToSingle(input, offset);
Expand All @@ -730,5 +738,6 @@ private static byte ClampByte(double x)
{
return byte.MaxValue < x ? byte.MaxValue : (x > byte.MinValue ? (byte)x : byte.MinValue);
}

}
}
9 changes: 5 additions & 4 deletions TextureDecoder/TextureDecoder.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net5.0;net6.0</TargetFrameworks>
<LangVersion>Latest</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RootNamespace>AssetRipper.TextureDecoder</RootNamespace>
<Authors>ds5678</Authors>
<Company>AssetRipper</Company>
<Version>1.0.2.0</Version>
<AssemblyVersion>1.0.2.0</AssemblyVersion>
<PackageId>TextureDecoder</PackageId>
<Version>1.1.0.0</Version>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<PackageId>AssetRipper.TextureDecoder</PackageId>
<PackageTags>C# Texture</PackageTags>
<RepositoryUrl>https://github.com/AssetRipper/TextureDecoder</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
2 changes: 1 addition & 1 deletion TextureDecoder/Yuy2/Yuy2Decoder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Runtime.CompilerServices;

namespace TextureDecoder.Yuy2
namespace AssetRipper.TextureDecoder.Yuy2
{
/// <summary>
///
Expand Down
2 changes: 1 addition & 1 deletion Yuy2Test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Diagnostics;
using System.Drawing.Imaging;
using System.IO;
using TextureDecoder.Yuy2;
using AssetRipper.TextureDecoder.Yuy2;

namespace Yuy2Test
{
Expand Down

0 comments on commit cab5cab

Please sign in to comment.