Skip to content

Commit

Permalink
Merge pull request #1938 from RussDev7/main
Browse files Browse the repository at this point in the history
Made Save-As-Version Button Loading Dynamic.
  • Loading branch information
RussDev7 committed Aug 5, 2024
2 parents add9b9e + ad09726 commit 9e096f3
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 176 deletions.
24 changes: 16 additions & 8 deletions src/TEdit/Editor/Plugins/ImageToPixelartEditorView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,14 @@ private async void ConvertToPixelArt_Click(object sender, RoutedEventArgs e)
// Check the current button content.
if (ConvertToPixelArt.Content.ToString() == "Convert To Pixel Art")
{
// Ensure the color filter is not zero.
if (ClrsTileWallData.Count == 0)
{
// Display error.
MessageBox.Show("The color filter is zero. Adjust your settings.");
return;
}

// Start or restart the conversion.
_cancellationTokenSource?.Cancel(); // Cancel any existing conversion tasks.
_cancellationTokenSource = new CancellationTokenSource(); // Create a new CancellationTokenSource for the new operation.
Expand Down Expand Up @@ -1255,7 +1263,7 @@ await Task.Run(() =>
using (g = Graphics.FromImage(bBt))
{
List<Color> block = new();
Color final = Color.Black;
Color final = Color.Lime;
int progressCounter = 0;
int progressUpdateInterval = Math.Max(totalBlocks / 100, 1); // Update progress every 1%. // Ensure progressUpdateInterval is at least 1.
Expand Down Expand Up @@ -1467,7 +1475,7 @@ private Color NearestNeighborInterpolation(Bitmap bmp, int x, int y, int num, bo
if (includeTransparent || nearestColor.A != 0)
{
if (includeTransparent && nearestColor.A == 0)
nearestColor = Color.Black; // Default color for transparency, or you can choose another default color.
nearestColor = Color.Lime; // Default color for transparency, or you can choose another default color.

return Clr(new Color[] { nearestColor });
}
Expand All @@ -1488,7 +1496,7 @@ private Color BilinearInterpolation(Bitmap bmp, int x, int y, int num, bool incl
if (includeTransparent || color.A != 0)
{
if (includeTransparent && color.A == 0)
color = Color.Black; // Default color for transparency, or you can choose another default color.
color = Color.Lime; // Default color for transparency, or you can choose another default color.
block.Add(color);
}
}
Expand Down Expand Up @@ -1528,7 +1536,7 @@ private Color BicubicInterpolation(Bitmap bmp, int x, int y, bool includeTranspa
if (includeTransparent || pixel.A != 0)
{
if (includeTransparent && pixel.A == 0)
pixel = Color.Black; // Default color for transparency, or you can choose another default color.
pixel = Color.Lime; // Default color for transparency, or you can choose another default color.

double coeff = dx[i + 1] * dy[j + 1];
r += pixel.R * coeff;
Expand Down Expand Up @@ -1565,7 +1573,7 @@ private Color LanczosInterpolation(Bitmap bmp, int x, int y, int num, int a, boo
if (includeTransparent || pixel.A != 0)
{
if (includeTransparent && pixel.A == 0)
pixel = Color.Black; // Default color for transparency, or you can choose another default color.
pixel = Color.Lime; // Default color for transparency, or you can choose another default color.

double lanczosWeight = LanczosKernel(i / (double)num, a) * LanczosKernel(j / (double)num, a);
r += pixel.R * lanczosWeight;
Expand Down Expand Up @@ -1610,7 +1618,7 @@ private Color HermiteInterpolation(Bitmap bmp, int x, int y, bool includeTranspa
if (includeTransparent || pixel.A != 0)
{
if (includeTransparent && pixel.A == 0)
pixel = Color.Black; // Default color for transparency, or you can choose another default color.
pixel = Color.Lime; // Default color for transparency, or you can choose another default color.

double coeff = dx[i] * dy[j];
r += pixel.R * coeff;
Expand Down Expand Up @@ -1648,7 +1656,7 @@ private Color SplineInterpolation(Bitmap bmp, int x, int y, int num, bool includ
if (includeTransparent || pixel.A != 0)
{
if (includeTransparent && pixel.A == 0)
pixel = Color.Black; // Default color for transparency, or you can choose another default color.
pixel = Color.Lime; // Default color for transparency, or you can choose another default color.

double coeff = SplineKernel(i / (double)num) * SplineKernel(j / (double)num);
r += pixel.R * coeff;
Expand Down Expand Up @@ -1688,7 +1696,7 @@ private Color GaussianInterpolation(Bitmap bmp, int x, int y, double sigma, bool
if (includeTransparent || pixel.A != 0)
{
if (includeTransparent && pixel.A == 0)
pixel = Color.Black; // Default color for transparency, or you can choose another default color.
pixel = Color.Lime; // Default color for transparency, or you can choose another default color.

double weight = GaussianKernel(i, j, sigma);
r += pixel.R * weight;
Expand Down
Loading

0 comments on commit 9e096f3

Please sign in to comment.