-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from DarthAffe/HPPH
Changed everything image-related to use HPPH
- Loading branch information
Showing
21 changed files
with
72 additions
and
1,879 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using HPPH; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace StableDiffusion.NET; | ||
|
||
internal static class ImageHelper | ||
{ | ||
public static unsafe Image<ColorRGB> ToImage(Native.sd_image_t* sdImage) | ||
{ | ||
int width = (int)sdImage->width; | ||
int height = (int)sdImage->height; | ||
int bpp = (int)sdImage->channel; | ||
|
||
Image<ColorRGB> image = Image<ColorRGB>.Create(new ReadOnlySpan<byte>(sdImage->data, width * height * bpp), width, height, width * bpp); | ||
|
||
Dispose(sdImage); | ||
|
||
return image; | ||
} | ||
|
||
public static unsafe void Dispose(Native.sd_image_t* image) | ||
{ | ||
Marshal.FreeHGlobal((nint)image->data); | ||
Marshal.FreeHGlobal((nint)image); | ||
} | ||
|
||
public static unsafe Native.sd_image_t ToSdImage(this IImage<ColorRGB> image, byte* pinnedReference) | ||
=> new() | ||
{ | ||
width = (uint)image.Width, | ||
height = (uint)image.Height, | ||
channel = (uint)image.ColorFormat.BytesPerPixel, | ||
data = pinnedReference | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.