Skip to content

Commit 17f3e34

Browse files
authored
Merge pull request #12 from DarthAffe/HPPH
Changed everything image-related to use HPPH
2 parents dc58d4d + c4311a1 commit 17f3e34

21 files changed

+72
-1879
lines changed

StableDiffusion.NET/Backends/RocmBackend.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Runtime.InteropServices;
33
using System.Text.RegularExpressions;
44
using JetBrains.Annotations;
5-
using StableDiffusion.NET.Helper;
65

76
namespace StableDiffusion.NET;
87

StableDiffusion.NET/Extensions/ImageExtension.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using HPPH;
2+
using System;
3+
using System.Runtime.InteropServices;
4+
5+
namespace StableDiffusion.NET;
6+
7+
internal static class ImageHelper
8+
{
9+
public static unsafe Image<ColorRGB> ToImage(Native.sd_image_t* sdImage)
10+
{
11+
int width = (int)sdImage->width;
12+
int height = (int)sdImage->height;
13+
int bpp = (int)sdImage->channel;
14+
15+
Image<ColorRGB> image = Image<ColorRGB>.Create(new ReadOnlySpan<byte>(sdImage->data, width * height * bpp), width, height, width * bpp);
16+
17+
Dispose(sdImage);
18+
19+
return image;
20+
}
21+
22+
public static unsafe void Dispose(Native.sd_image_t* image)
23+
{
24+
Marshal.FreeHGlobal((nint)image->data);
25+
Marshal.FreeHGlobal((nint)image);
26+
}
27+
28+
public static unsafe Native.sd_image_t ToSdImage(this IImage<ColorRGB> image, byte* pinnedReference)
29+
=> new()
30+
{
31+
width = (uint)image.Width,
32+
height = (uint)image.Height,
33+
channel = (uint)image.ColorFormat.BytesPerPixel,
34+
data = pinnedReference
35+
};
36+
}

StableDiffusion.NET/Helper/Images/Colors/ColorABGR.cs

Lines changed: 0 additions & 66 deletions
This file was deleted.

StableDiffusion.NET/Helper/Images/Colors/ColorARGB.cs

Lines changed: 0 additions & 66 deletions
This file was deleted.

StableDiffusion.NET/Helper/Images/Colors/ColorBGR.cs

Lines changed: 0 additions & 63 deletions
This file was deleted.

StableDiffusion.NET/Helper/Images/Colors/ColorBGRA.cs

Lines changed: 0 additions & 66 deletions
This file was deleted.

StableDiffusion.NET/Helper/Images/Colors/ColorFormat.cs

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)