Skip to content

Commit

Permalink
Merge pull request #12 from DarthAffe/HPPH
Browse files Browse the repository at this point in the history
Changed everything image-related to use HPPH
  • Loading branch information
DarthAffe authored Jul 22, 2024
2 parents dc58d4d + c4311a1 commit 17f3e34
Show file tree
Hide file tree
Showing 21 changed files with 72 additions and 1,879 deletions.
1 change: 0 additions & 1 deletion StableDiffusion.NET/Backends/RocmBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using JetBrains.Annotations;
using StableDiffusion.NET.Helper;

namespace StableDiffusion.NET;

Expand Down
9 changes: 0 additions & 9 deletions StableDiffusion.NET/Extensions/ImageExtension.cs

This file was deleted.

36 changes: 36 additions & 0 deletions StableDiffusion.NET/Helper/ImageHelper.cs
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
};
}
66 changes: 0 additions & 66 deletions StableDiffusion.NET/Helper/Images/Colors/ColorABGR.cs

This file was deleted.

66 changes: 0 additions & 66 deletions StableDiffusion.NET/Helper/Images/Colors/ColorARGB.cs

This file was deleted.

63 changes: 0 additions & 63 deletions StableDiffusion.NET/Helper/Images/Colors/ColorBGR.cs

This file was deleted.

66 changes: 0 additions & 66 deletions StableDiffusion.NET/Helper/Images/Colors/ColorBGRA.cs

This file was deleted.

58 changes: 0 additions & 58 deletions StableDiffusion.NET/Helper/Images/Colors/ColorFormat.cs

This file was deleted.

Loading

0 comments on commit 17f3e34

Please sign in to comment.