Compare commits
No commits in common. "09b5238b248e0c572f3880b8eaabf040161ba217" and "ff83cb20f95d432f36ce1e0c3c285a13ea1d9a1c" have entirely different histories.
09b5238b24
...
ff83cb20f9
12
NativeTypeNameAttribute.cs
Normal file
12
NativeTypeNameAttribute.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace Quik.Stb
|
||||
{
|
||||
[AttributeUsage(System.AttributeTargets.All, Inherited = false, AllowMultiple = true)]
|
||||
internal sealed class NativeTypeNameAttribute : System.Attribute
|
||||
{
|
||||
public NativeTypeNameAttribute(string typename)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
<!-- Nuget Properties. -->
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
<PackageId>ReFuel.StbImage</PackageId>
|
||||
<Version>2.0.2-rc.0</Version>
|
||||
<Version>2.0.1</Version>
|
||||
<Authors>STBI Authors, H. Utku Maden</Authors>
|
||||
<Description>
|
||||
A C# wrapper for the ubiquitous stb_image.h and stb_image_write.h library.
|
||||
@ -26,10 +26,7 @@
|
||||
<RepositoryUrl>https://git.mixedup.dev/ReFuel/ReFuel.StbImage</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<PackageTags>stb; stb_image; stbi; image; load; save; read; write</PackageTags>
|
||||
<PackageReleaseNotes># 2.0.2
|
||||
* Fixed calling convention related execution engine exception for the Windows platform.
|
||||
|
||||
# 2.0.1
|
||||
<PackageReleaseNotes># 2.0.1
|
||||
* Enabled optimizations across the board for native and managed assemblies.
|
||||
|
||||
# 2.0.0
|
||||
|
22
StbImage.cs
22
StbImage.cs
@ -33,7 +33,6 @@ namespace ReFuel.Stb
|
||||
/// Internal image format.
|
||||
/// </summary>
|
||||
public StbiImageFormat Format { get; }
|
||||
|
||||
/// <summary>
|
||||
/// True if the image is a floating point image.
|
||||
/// </summary>
|
||||
@ -67,7 +66,7 @@ namespace ReFuel.Stb
|
||||
StbiImageFormat.GreyAlpha => 2,
|
||||
StbiImageFormat.Rgb => 3,
|
||||
StbiImageFormat.Rgba => 4,
|
||||
_ => throw new Exception("unknown image format")
|
||||
_ => throw new Exception("unkown image format")
|
||||
} * (IsFloat ? sizeof(float) : sizeof(byte));
|
||||
|
||||
return new ReadOnlySpan<T>((T*)ImagePointer, Width * Height * sz / sizeof(T));
|
||||
@ -113,7 +112,6 @@ namespace ReFuel.Stb
|
||||
/// Write image to a PNG file.
|
||||
/// </summary>
|
||||
/// <param name="dest">The destination stream.</param>
|
||||
/// <param name="quality">The JPEG quality factor.</param>
|
||||
/// <remarks>
|
||||
/// Incurs a conversion cost if the image format is not a byte format. Ignores alpha channel. Affected by non-thread safe global options.
|
||||
/// </remarks>
|
||||
@ -151,7 +149,7 @@ namespace ReFuel.Stb
|
||||
/// According to the stb_image documentation, only iPhone PNG images
|
||||
/// can come with premultiplied alpha.
|
||||
/// </remarks>
|
||||
public static bool UnpremultiplyOnLoad { set => Stbi.set_unpremultiply_on_load(value ? 1 : 0); }
|
||||
public static bool UnpremultiplyOnLoad { set => Stbi.set_unpremultiply_on_load(1); }
|
||||
|
||||
/// <summary>
|
||||
/// Force a filter on PNG filter when saving.
|
||||
@ -203,13 +201,13 @@ namespace ReFuel.Stb
|
||||
/// <param name="image">The resulting image.</param>
|
||||
/// <param name="stream">Source stream.</param>
|
||||
/// <param name="format">The desired image format.</param>
|
||||
/// <param name="asFloat">The buffer uses floating point pixels if true.</param>
|
||||
/// <returns>True on success.</returns>
|
||||
public static bool TryLoad([NotNullWhen(true)] out StbImage? image, Stream stream, StbiImageFormat format = StbiImageFormat.Default, bool asFloat = false)
|
||||
{
|
||||
int x, y, iFormat;
|
||||
StbiStreamWrapper wrapper = new StbiStreamWrapper(stream, true);
|
||||
wrapper.CreateCallbacks(out stbi_io_callbacks cb);
|
||||
|
||||
stream.Position = 0;
|
||||
IntPtr imagePtr;
|
||||
if (asFloat)
|
||||
@ -239,7 +237,6 @@ namespace ReFuel.Stb
|
||||
/// <param name="image">The resulting image.</param>
|
||||
/// <param name="span">Source memory span.</param>
|
||||
/// <param name="format">The desired image format.</param>
|
||||
/// <param name="asFloat">The buffer uses floating point pixels if true.</param>
|
||||
/// <returns>True on success.</returns>
|
||||
public static bool TryLoad([NotNullWhen(true)] out StbImage? image, ReadOnlySpan<byte> span, StbiImageFormat format = StbiImageFormat.Default, bool asFloat = false)
|
||||
{
|
||||
@ -274,7 +271,6 @@ namespace ReFuel.Stb
|
||||
/// </summary>
|
||||
/// <param name="stream">The stream to load from.</param>
|
||||
/// <param name="format">The desired image format.</param>
|
||||
/// <param name="asFloat">The buffer uses floating point pixels if true.</param>
|
||||
/// <returns>The image object.</returns>
|
||||
public static StbImage Load(Stream stream, StbiImageFormat format = StbiImageFormat.Default, bool asFloat = false)
|
||||
{
|
||||
@ -292,7 +288,6 @@ namespace ReFuel.Stb
|
||||
/// </summary>
|
||||
/// <param name="span">The span of memory to load from.</param>
|
||||
/// <param name="format">The desired image format.</param>
|
||||
/// <param name="asFloat">The buffer uses floating point pixels if true.</param>
|
||||
/// <returns>The image object.</returns>
|
||||
public static StbImage Load(ReadOnlySpan<byte> span, StbiImageFormat format = StbiImageFormat.Default, bool asFloat = false)
|
||||
{
|
||||
@ -394,7 +389,7 @@ namespace ReFuel.Stb
|
||||
/// <param name="data">Span of pixel data.</param>
|
||||
/// <param name="width">Width of the pixel data in pixels.</param>
|
||||
/// <param name="height">Height of the pixel data in pixels.</param>
|
||||
/// <param name="format">Color format of the pixel data. Must not be <see cref="StbiImageFormat"/>.</param>
|
||||
/// <param name="format">Color format of the pixel data. Must not be <see cref="StbiImageFormat.StbiImageFormat"/>.</param>
|
||||
/// <param name="destination">The destination stream.</param>
|
||||
/// <param name="isFloat">True if the pixel format in data is a floating point format.</param>
|
||||
/// <remarks>
|
||||
@ -430,7 +425,7 @@ namespace ReFuel.Stb
|
||||
/// <param name="data">Span of pixel data.</param>
|
||||
/// <param name="width">Width of the pixel data in pixels.</param>
|
||||
/// <param name="height">Height of the pixel data in pixels.</param>
|
||||
/// <param name="format">Color format of the pixel data. Must not be <see cref="StbiImageFormat"/>.</param>
|
||||
/// <param name="format">Color format of the pixel data. Must not be <see cref="StbiImageFormat.StbiImageFormat"/>.</param>
|
||||
/// <param name="destination">The destination stream.</param>
|
||||
/// <param name="isFloat">True if the pixel format in data is a floating point format.</param>
|
||||
/// <remarks>
|
||||
@ -466,7 +461,7 @@ namespace ReFuel.Stb
|
||||
/// <param name="data">Span of pixel data.</param>
|
||||
/// <param name="width">Width of the pixel data in pixels.</param>
|
||||
/// <param name="height">Height of the pixel data in pixels.</param>
|
||||
/// <param name="format">Color format of the pixel data. Must not be <see cref="StbiImageFormat"/>.</param>
|
||||
/// <param name="format">Color format of the pixel data. Must not be <see cref="StbiImageFormat.StbiImageFormat"/>.</param>
|
||||
/// <param name="destination">The destination stream.</param>
|
||||
/// <param name="isFloat">True if the pixel format in data is a floating point format.</param>
|
||||
/// <remarks>
|
||||
@ -502,7 +497,7 @@ namespace ReFuel.Stb
|
||||
/// <param name="data">Span of pixel data.</param>
|
||||
/// <param name="width">Width of the pixel data in pixels.</param>
|
||||
/// <param name="height">Height of the pixel data in pixels.</param>
|
||||
/// <param name="format">Color format of the pixel data. Must not be <see cref="StbiImageFormat"/>.</param>
|
||||
/// <param name="format">Color format of the pixel data. Must not be <see cref="StbiImageFormat.StbiImageFormat"/>.</param>
|
||||
/// <param name="destination">The destination stream.</param>
|
||||
/// <param name="isFloat">True if the pixel format in data is a floating point format.</param>
|
||||
/// <remarks>
|
||||
@ -538,9 +533,8 @@ namespace ReFuel.Stb
|
||||
/// <param name="data">Span of pixel data.</param>
|
||||
/// <param name="width">Width of the pixel data in pixels.</param>
|
||||
/// <param name="height">Height of the pixel data in pixels.</param>
|
||||
/// <param name="format">Color format of the pixel data. Must not be <see cref="StbiImageFormat"/>.</param>
|
||||
/// <param name="format">Color format of the pixel data. Must not be <see cref="StbiImageFormat.StbiImageFormat"/>.</param>
|
||||
/// <param name="destination">The destination stream.</param>
|
||||
/// <param name="quality">The JPEG quality factor.</param>
|
||||
/// <param name="isFloat">True if the pixel format in data is a floating point format.</param>
|
||||
/// <remarks>
|
||||
/// This will incur a conversion cost if the pixel format is not a byte format. Ignores the alpha channel. Affected by global non-thread safe options.
|
||||
|
@ -12,23 +12,18 @@ namespace ReFuel.Stb
|
||||
/// <param name="buffer">C array to read into.</param>
|
||||
/// <param name="count">Size of the C array in bytes.</param>
|
||||
/// <returns>The number of bytes read from the stream.</returns>
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public unsafe delegate int StbiReadProc(void *userdata, byte* buffer, int count);
|
||||
|
||||
/// <summary>
|
||||
/// Pointer to STBI stream skip function.
|
||||
/// </summary>
|
||||
/// <param name="userdata">User provided userdata pointer.</param>
|
||||
/// <param name="count">Number of bytes to skip.</param>
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public unsafe delegate void StbiSkipProc(void *userdata, int count);
|
||||
|
||||
/// <summary>
|
||||
/// Pointer to STBI stream end of file function.
|
||||
/// </summary>
|
||||
/// <param name="userdata">User provided userdata pointer.</param>
|
||||
/// <returns>Non-zero value if the end of the stream has been reached.</returns>
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public unsafe delegate int StbiEofProc(void *userdata);
|
||||
|
||||
/// <summary>
|
||||
|
@ -9,7 +9,6 @@ namespace ReFuel.Stb.Native
|
||||
/// <param name="context">User provided context pointer.</param>
|
||||
/// <param name="data">C Array of data to write.</param>
|
||||
/// <param name="size">Size of the C array in bytes.</param>
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public unsafe delegate void StbiWriteProc(void* context, void* data, int size);
|
||||
|
||||
public unsafe partial class Stbi
|
||||
|
Loading…
Reference in New Issue
Block a user