Skip to content

Changed everything image-related to use HPPH #12

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

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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