From 7157db6bd06b9450887f1f85212e14f319fc9a0d Mon Sep 17 00:00:00 2001 From: "H. Utku Maden" Date: Mon, 18 Nov 2024 19:57:50 +0300 Subject: [PATCH] Additional documentation. --- StbImage.cs | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/StbImage.cs b/StbImage.cs index 2b970b2..46982cc 100644 --- a/StbImage.cs +++ b/StbImage.cs @@ -33,6 +33,7 @@ namespace ReFuel.Stb /// Internal image format. /// public StbiImageFormat Format { get; } + /// /// True if the image is a floating point image. /// @@ -66,7 +67,7 @@ namespace ReFuel.Stb StbiImageFormat.GreyAlpha => 2, StbiImageFormat.Rgb => 3, StbiImageFormat.Rgba => 4, - _ => throw new Exception("unkown image format") + _ => throw new Exception("unknown image format") } * (IsFloat ? sizeof(float) : sizeof(byte)); return new ReadOnlySpan((T*)ImagePointer, Width * Height * sz / sizeof(T)); @@ -80,7 +81,7 @@ namespace ReFuel.Stb /// Incurs a conversion cost if the image format is not a byte format. Affected by non-thread safe global options. /// public void WritePng(Stream dest) => WritePng(AsSpan(), Width, Height, Format, dest, isFloat: IsFloat); - + /// /// Write image to a BMP file. /// @@ -89,7 +90,7 @@ namespace ReFuel.Stb /// Incurs a conversion cost if the image format is not a byte format. Affected by non-thread safe global options. /// public void WriteBmp(Stream dest) => WriteBmp(AsSpan(), Width, Height, Format, dest, isFloat: IsFloat); - + /// /// Write image to a TGA file. /// @@ -98,7 +99,7 @@ namespace ReFuel.Stb /// Incurs a conversion cost if the image format is not a byte format. Ignores alpha channel. Affected by non-thread safe global options. /// public void WriteTga(Stream dest) => WriteTga(AsSpan(), Width, Height, Format, dest, isFloat: IsFloat); - + /// /// Write image to a PNG file. /// @@ -107,11 +108,12 @@ namespace ReFuel.Stb /// Incurs a conversion cost if the image format is not a float format. Affected by non-thread safe global options. /// public void WriteHdr(Stream dest) => WriteHdr(AsSpan(), Width, Height, Format, dest, isFloat: IsFloat); - + /// /// Write image to a PNG file. /// /// The destination stream. + /// The JPEG quality factor. /// /// Incurs a conversion cost if the image format is not a byte format. Ignores alpha channel. Affected by non-thread safe global options. /// @@ -201,13 +203,13 @@ namespace ReFuel.Stb /// The resulting image. /// Source stream. /// The desired image format. + /// The buffer uses floating point pixels if true. /// True on success. 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) @@ -237,6 +239,7 @@ namespace ReFuel.Stb /// The resulting image. /// Source memory span. /// The desired image format. + /// The buffer uses floating point pixels if true. /// True on success. public static bool TryLoad([NotNullWhen(true)] out StbImage? image, ReadOnlySpan span, StbiImageFormat format = StbiImageFormat.Default, bool asFloat = false) { @@ -271,6 +274,7 @@ namespace ReFuel.Stb /// /// The stream to load from. /// The desired image format. + /// The buffer uses floating point pixels if true. /// The image object. public static StbImage Load(Stream stream, StbiImageFormat format = StbiImageFormat.Default, bool asFloat = false) { @@ -288,6 +292,7 @@ namespace ReFuel.Stb /// /// The span of memory to load from. /// The desired image format. + /// The buffer uses floating point pixels if true. /// The image object. public static StbImage Load(ReadOnlySpan span, StbiImageFormat format = StbiImageFormat.Default, bool asFloat = false) { @@ -389,7 +394,7 @@ namespace ReFuel.Stb /// Span of pixel data. /// Width of the pixel data in pixels. /// Height of the pixel data in pixels. - /// Color format of the pixel data. Must not be . + /// Color format of the pixel data. Must not be . /// The destination stream. /// True if the pixel format in data is a floating point format. /// @@ -425,7 +430,7 @@ namespace ReFuel.Stb /// Span of pixel data. /// Width of the pixel data in pixels. /// Height of the pixel data in pixels. - /// Color format of the pixel data. Must not be . + /// Color format of the pixel data. Must not be . /// The destination stream. /// True if the pixel format in data is a floating point format. /// @@ -461,7 +466,7 @@ namespace ReFuel.Stb /// Span of pixel data. /// Width of the pixel data in pixels. /// Height of the pixel data in pixels. - /// Color format of the pixel data. Must not be . + /// Color format of the pixel data. Must not be . /// The destination stream. /// True if the pixel format in data is a floating point format. /// @@ -497,7 +502,7 @@ namespace ReFuel.Stb /// Span of pixel data. /// Width of the pixel data in pixels. /// Height of the pixel data in pixels. - /// Color format of the pixel data. Must not be . + /// Color format of the pixel data. Must not be . /// The destination stream. /// True if the pixel format in data is a floating point format. /// @@ -533,8 +538,9 @@ namespace ReFuel.Stb /// Span of pixel data. /// Width of the pixel data in pixels. /// Height of the pixel data in pixels. - /// Color format of the pixel data. Must not be . + /// Color format of the pixel data. Must not be . /// The destination stream. + /// The JPEG quality factor. /// True if the pixel format in data is a floating point format. /// /// 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. @@ -562,4 +568,4 @@ namespace ReFuel.Stb Stbi.write_jpg_to_func(wrapper, null, width, height, components, ptr, quality); } } -} \ No newline at end of file +}