Skip to content
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

Made Save-As-Version Button Loading Dynamic. #1938

Merged
merged 2 commits into from
Aug 5, 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
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
Loading