-
-
Notifications
You must be signed in to change notification settings - Fork 852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose Span methods on LoadPixelData and SavePixelData #567
Changes from 10 commits
92ab411
cddab85
54791bf
c6c9ae8
1653a93
ea38b24
bddc20a
1c79b08
5156890
15494b4
00af2df
eb318a3
fd766a5
017c7fb
fda2d1f
4f779ca
46e0a85
202e472
45e5d5b
09a77e4
a05b618
92f353b
1695b59
63dc698
93c44f4
05aa089
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ public static Image<TPixel> LoadPixelData<TPixel>(TPixel[] data, int width, int | |
/// <param name="height">The height of the final image.</param> | ||
/// <typeparam name="TPixel">The pixel format.</typeparam> | ||
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> | ||
private static Image<TPixel> LoadPixelData<TPixel>(Span<TPixel> data, int width, int height) | ||
public static Image<TPixel> LoadPixelData<TPixel>(Span<TPixel> data, int width, int height) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should consume There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My mistake that I also forgot about this in #565 :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. I'll update the PR shortly. Also need to figure out why that test is failing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
where TPixel : struct, IPixel<TPixel> | ||
=> LoadPixelData(Configuration.Default, data, width, height); | ||
|
||
|
@@ -57,7 +57,7 @@ public static Image<TPixel> LoadPixelData<TPixel>(byte[] data, int width, int he | |
/// <param name="height">The height of the final image.</param> | ||
/// <typeparam name="TPixel">The pixel format.</typeparam> | ||
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> | ||
private static Image<TPixel> LoadPixelData<TPixel>(Span<byte> data, int width, int height) | ||
public static Image<TPixel> LoadPixelData<TPixel>(Span<byte> data, int width, int height) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
where TPixel : struct, IPixel<TPixel> | ||
=> LoadPixelData<TPixel>(Configuration.Default, data, width, height); | ||
|
||
|
@@ -83,7 +83,7 @@ public static Image<TPixel> LoadPixelData<TPixel>(Configuration config, byte[] d | |
/// <param name="height">The height of the final image.</param> | ||
/// <typeparam name="TPixel">The pixel format.</typeparam> | ||
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> | ||
private static Image<TPixel> LoadPixelData<TPixel>(Configuration config, Span<byte> data, int width, int height) | ||
public static Image<TPixel> LoadPixelData<TPixel>(Configuration config, Span<byte> data, int width, int height) | ||
where TPixel : struct, IPixel<TPixel> | ||
=> LoadPixelData(config, MemoryMarshal.Cast<byte, TPixel>(data), width, height); | ||
|
||
|
@@ -111,7 +111,7 @@ public static Image<TPixel> LoadPixelData<TPixel>(Configuration config, TPixel[] | |
/// <param name="height">The height of the final image.</param> | ||
/// <typeparam name="TPixel">The pixel format.</typeparam> | ||
/// <returns>A new <see cref="Image{TPixel}"/>.</returns> | ||
private static Image<TPixel> LoadPixelData<TPixel>(Configuration config, Span<TPixel> data, int width, int height) | ||
public static Image<TPixel> LoadPixelData<TPixel>(Configuration config, Span<TPixel> data, int width, int height) | ||
where TPixel : struct, IPixel<TPixel> | ||
{ | ||
int count = width * height; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,10 @@ public static TPixel FromRGBA(byte red, byte green, byte blue, byte alpha) | |
/// </returns> | ||
private static string ToRgbaHex(string hex) | ||
{ | ||
hex = hex.StartsWith("#") ? hex.Substring(1) : hex; | ||
if (hex[0] == '#') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this will fail if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This methods only caller is guarding against null and empty. I added some tests to verify this behavior. |
||
{ | ||
hex = hex.Substring(1); | ||
} | ||
|
||
if (hex.Length == 8) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't this fail if
this.palette
isn't the correct length? just raising this as a subtle change of behavior that might introduce exceptions that previously (potentially incorrectly) allowed.note: not asking for a change just pointing it out incase someone else thinks its important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should only throw if the we try indexing into the palette outside it's bounds.