Skip to content

Commit

Permalink
add some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneWandererProductions committed May 29, 2024
1 parent 5947aea commit 8a542f5
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions Imaging/ImageStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,13 +1110,20 @@ internal static Bitmap ConvertWhiteToTransparent(Bitmap image, int threshold)
/// <summary>
/// Pixelate the specified input image.
/// </summary>
/// <param name="inputImage">The input image.</param>
/// <param name="image">The input image.</param>
/// <param name="stepWidth">Width of the step.</param>
/// <returns>Pixelated Image</returns>
internal static Bitmap Pixelate(Bitmap inputImage, int stepWidth)
internal static Bitmap Pixelate(Bitmap image, int stepWidth)
{
if (image == null)
{
var innerException = new ArgumentNullException(string.Concat(nameof(ConvertWhiteToTransparent),
ImagingResources.Spacing, nameof(image)));
throw new ArgumentNullException(ImagingResources.ErrorWrongParameters, innerException);
}

// Create a new bitmap to store the processed image
var dbm = new DirectBitmap(inputImage);
var dbm = new DirectBitmap(image);
// Create a new bitmap to store the processed image
var processedImage = new Bitmap(dbm.Width, dbm.Height);

Expand All @@ -1126,7 +1133,7 @@ internal static Bitmap Pixelate(Bitmap inputImage, int stepWidth)
for (var x = 0; x < dbm.Width; x += stepWidth)
{
// Get the color of the current rectangle
var averageColor = GetAverageColor(inputImage, x, y, stepWidth, stepWidth);
var averageColor = GetAverageColor(image, x, y, stepWidth, stepWidth);

using var g = Graphics.FromImage(processedImage);
using var brush = new SolidBrush(averageColor);
Expand Down Expand Up @@ -1272,7 +1279,7 @@ internal static Bitmap SetPixel(Bitmap image, Point point, Color color, int radi
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <returns>Average Color of the Area</returns>
private static Color GetAverageColor(Bitmap inputImage, int startX, int startY, int width, int height)
private static Color GetAverageColor(Image inputImage, int startX, int startY, int width, int height)
{
var totalRed = 0;
var totalGreen = 0;
Expand Down Expand Up @@ -1308,6 +1315,12 @@ private static Color GetAverageColor(Bitmap inputImage, int startX, int startY,
return Color.FromArgb(averageRed, averageGreen, averageBlue);
}

// TODO add:
// Prewitt
// Roberts Cross
// Laplacian
// Laplacian of Gaussain

/// <summary>
/// Applies the Sobel.
/// </summary>
Expand Down

0 comments on commit 8a542f5

Please sign in to comment.