Skip to content

Commit f3bd2b8

Browse files
Load <Rgba32> directly and fix typos
regarding PR suggestion.
1 parent fc3860f commit f3bd2b8

File tree

1 file changed

+17
-16
lines changed
  • IronSoftware.Drawing/IronSoftware.Drawing.Common

1 file changed

+17
-16
lines changed

IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ public T ToBitmap<T>()
462462
/// Create a new Bitmap from a a Byte Span.
463463
/// </summary>
464464
/// <param name="span">A Byte Span of image data in any common format.</param>
465-
/// <param name="preserveOriginalFormat">Determine wheter load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
465+
/// <param name="preserveOriginalFormat">Determine whether load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
466466
/// Default is true. Set to false to load as Rgba32.</param>
467467
public static AnyBitmap FromSpan(ReadOnlySpan<byte> span, bool preserveOriginalFormat = true)
468468
{
@@ -473,7 +473,7 @@ public static AnyBitmap FromSpan(ReadOnlySpan<byte> span, bool preserveOriginalF
473473
/// Create a new Bitmap from a a Byte Array.
474474
/// </summary>
475475
/// <param name="bytes">A ByteArray of image data in any common format.</param>
476-
/// <param name="preserveOriginalFormat">Determine wheter load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
476+
/// <param name="preserveOriginalFormat">Determine whether load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
477477
/// Default is true. Set to false to load as Rgba32.</param>
478478
public static AnyBitmap FromBytes(byte[] bytes, bool preserveOriginalFormat = true)
479479
{
@@ -484,7 +484,7 @@ public static AnyBitmap FromBytes(byte[] bytes, bool preserveOriginalFormat = tr
484484
/// Create a new Bitmap from a <see cref="Stream"/> (bytes).
485485
/// </summary>
486486
/// <param name="stream">A <see cref="Stream"/> of image data in any common format.</param>
487-
/// <param name="preserveOriginalFormat">Determine wheter load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
487+
/// <param name="preserveOriginalFormat">Determine whether load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
488488
/// Default is true. Set to false to load as Rgba32.</param>
489489
/// <seealso cref="FromStream(Stream, bool)"/>
490490
/// <seealso cref="AnyBitmap"/>
@@ -497,7 +497,7 @@ public static AnyBitmap FromStream(MemoryStream stream, bool preserveOriginalFor
497497
/// Create a new Bitmap from a <see cref="Stream"/> (bytes).
498498
/// </summary>
499499
/// <param name="stream">A <see cref="Stream"/> of image data in any common format.</param>
500-
/// <param name="preserveOriginalFormat">Determine wheter load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
500+
/// <param name="preserveOriginalFormat">Determine whether load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
501501
/// Default is true. Set to false to load as Rgba32.</param>
502502
/// <seealso cref="FromStream(MemoryStream, bool)"/>
503503
/// <seealso cref="AnyBitmap"/>
@@ -510,7 +510,7 @@ public static AnyBitmap FromStream(Stream stream, bool preserveOriginalFormat =
510510
/// Construct a new Bitmap from binary data (byte span).
511511
/// </summary>
512512
/// <param name="span">A byte span of image data in any common format.</param>
513-
/// <param name="preserveOriginalFormat">Determine wheter load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
513+
/// <param name="preserveOriginalFormat">Determine whether load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
514514
/// Default is true. Set to false to load as Rgba32.</param>
515515
/// <seealso cref="AnyBitmap"/>
516516
public AnyBitmap(ReadOnlySpan<byte> span, bool preserveOriginalFormat = true)
@@ -522,7 +522,7 @@ public AnyBitmap(ReadOnlySpan<byte> span, bool preserveOriginalFormat = true)
522522
/// Construct a new Bitmap from binary data (bytes).
523523
/// </summary>
524524
/// <param name="bytes">A ByteArray of image data in any common format.</param>
525-
/// <param name="preserveOriginalFormat">Determine wheter load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
525+
/// <param name="preserveOriginalFormat">Determine whether load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
526526
/// Default is true. Set to false to load as Rgba32.</param>
527527
/// <seealso cref="FromBytes"/>
528528
/// <seealso cref="AnyBitmap"/>
@@ -535,7 +535,7 @@ public AnyBitmap(byte[] bytes, bool preserveOriginalFormat = true)
535535
/// Construct a new Bitmap from a <see cref="Stream"/> (bytes).
536536
/// </summary>
537537
/// <param name="stream">A <see cref="Stream"/> of image data in any common format.</param>
538-
/// <param name="preserveOriginalFormat">Determine wheter load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
538+
/// <param name="preserveOriginalFormat">Determine whether load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
539539
/// Default is true. Set to false to load as Rgba32.</param>
540540
/// <seealso cref="FromStream(Stream, bool)"/>
541541
/// <seealso cref="AnyBitmap"/>
@@ -548,7 +548,7 @@ public AnyBitmap(MemoryStream stream, bool preserveOriginalFormat = true)
548548
/// Construct a new Bitmap from a <see cref="Stream"/> (bytes).
549549
/// </summary>
550550
/// <param name="stream">A <see cref="Stream"/> of image data in any common format.</param>
551-
/// <param name="preserveOriginalFormat">Determine wheter load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
551+
/// <param name="preserveOriginalFormat">Determine whether load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
552552
/// Default is true. Set to false to load as Rgba32.</param>
553553
/// <seealso cref="FromStream(MemoryStream, bool)"/>
554554
/// <seealso cref="AnyBitmap"/>
@@ -573,7 +573,7 @@ public AnyBitmap(AnyBitmap original, int width, int height)
573573
/// Construct a new Bitmap from a file.
574574
/// </summary>
575575
/// <param name="file">A fully qualified file path./</param>
576-
/// <param name="preserveOriginalFormat">Determine wheter load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
576+
/// <param name="preserveOriginalFormat">Determine whether load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
577577
/// Default is true. Set to false to load as Rgba32.</param>
578578
/// <seealso cref="FromFile"/>
579579
/// <seealso cref="AnyBitmap"/>
@@ -586,7 +586,7 @@ public AnyBitmap(string file, bool preserveOriginalFormat = true)
586586
/// Construct a new Bitmap from a Uri
587587
/// </summary>
588588
/// <param name="uri">The uri of the image.</param>
589-
/// <param name="preserveOriginalFormat">Determine wheter load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
589+
/// <param name="preserveOriginalFormat">Determine whether load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
590590
/// Default is true. Set to false to load as Rgba32.</param>
591591
/// <seealso cref="FromUriAsync"/>
592592
/// <seealso cref="AnyBitmap"/>
@@ -618,7 +618,7 @@ public AnyBitmap(int width, int height, Color backgroundColor = null)
618618
/// Create a new Bitmap from a file.
619619
/// </summary>
620620
/// <param name="file">A fully qualified file path.</param>
621-
/// <param name="preserveOriginalFormat">Determine wheter load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
621+
/// <param name="preserveOriginalFormat">Determine whether load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
622622
/// Default is true. Set to false to load as Rgba32.</param>
623623
/// <seealso cref="FromFile"/>
624624
/// <seealso cref="AnyBitmap"/>
@@ -638,7 +638,7 @@ public static AnyBitmap FromFile(string file, bool preserveOriginalFormat = true
638638
/// Construct a new Bitmap from a Uri
639639
/// </summary>
640640
/// <param name="uri">The uri of the image.</param>
641-
/// <param name="preserveOriginalFormat">Determine wheter load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
641+
/// <param name="preserveOriginalFormat">Determine whether load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
642642
/// Default is true. Set to false to load as Rgba32.</param>
643643
/// <returns></returns>
644644
/// <seealso cref="AnyBitmap"/>
@@ -661,7 +661,7 @@ public static async Task<AnyBitmap> FromUriAsync(Uri uri, bool preserveOriginalF
661661
/// Construct a new Bitmap from a Uri
662662
/// </summary>
663663
/// <param name="uri">The uri of the image.</param>
664-
/// <param name="preserveOriginalFormat">Determine wheter load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
664+
/// <param name="preserveOriginalFormat">Determine whether load <see cref="SixLabors.ImageSharp.Image"/> as its original pixel format or Rgba32.
665665
/// Default is true. Set to false to load as Rgba32.</param>
666666
/// <returns></returns>
667667
/// <seealso cref="AnyBitmap"/>
@@ -2051,10 +2051,11 @@ private void LoadImage(ReadOnlySpan<byte> bytes, bool preserveOriginalFormat)
20512051
Binary = bytes.ToArray();
20522052
Image = Image.Load(bytes);
20532053

2054-
if (!preserveOriginalFormat)
2054+
if (preserveOriginalFormat)
2055+
Image = Image.Load(bytes);
2056+
else
20552057
{
2056-
if (Image is not Image<Rgba32>)
2057-
Image = Image.CloneAs<Rgba32>();
2058+
Image = Image.Load<Rgba32>(bytes);
20582059

20592060
// .png image pre-processing
20602061
if (Format.Name == "PNG")

0 commit comments

Comments
 (0)