mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Renamed matrix brightness to gamma
This commit is contained in:
@@ -465,7 +465,7 @@ namespace GHelper.AnimeMatrix
|
||||
|
||||
int matrixZoom = AppConfig.Get("matrix_zoom", 100);
|
||||
int matrixContrast = AppConfig.Get("matrix_contrast", 100);
|
||||
int matrixBrightness = AppConfig.Get("matrix_brightness", 0);
|
||||
int matrixGamma = AppConfig.Get("matrix_gamma", 0);
|
||||
|
||||
int matrixSpeed = AppConfig.Get("matrix_speed", 50);
|
||||
|
||||
@@ -487,9 +487,9 @@ namespace GHelper.AnimeMatrix
|
||||
image.SelectActiveFrame(dimension, i);
|
||||
|
||||
if (rotation == MatrixRotation.Planar)
|
||||
deviceMatrix.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast, matrixBrightness);
|
||||
deviceMatrix.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast, matrixGamma);
|
||||
else
|
||||
deviceMatrix.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast, matrixBrightness);
|
||||
deviceMatrix.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast, matrixGamma);
|
||||
|
||||
deviceMatrix.AddFrame();
|
||||
}
|
||||
@@ -504,9 +504,9 @@ namespace GHelper.AnimeMatrix
|
||||
else
|
||||
{
|
||||
if (rotation == MatrixRotation.Planar)
|
||||
deviceMatrix.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast, matrixBrightness);
|
||||
deviceMatrix.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast, matrixGamma);
|
||||
else
|
||||
deviceMatrix.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast, matrixBrightness);
|
||||
deviceMatrix.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast, matrixGamma);
|
||||
|
||||
deviceMatrix.Present();
|
||||
}
|
||||
|
||||
@@ -344,21 +344,21 @@ namespace GHelper.AnimeMatrix
|
||||
if (present) Present();
|
||||
}
|
||||
|
||||
private void SetBitmapDiagonal(Bitmap bmp, int deltaX = 0, int deltaY = 0, int contrast = 100, int brightness = 0)
|
||||
private void SetBitmapDiagonal(Bitmap bmp, int deltaX = 0, int deltaY = 0, int contrast = 100, int gamma = 0)
|
||||
{
|
||||
for (int y = 0; y < bmp.Height; y++)
|
||||
{
|
||||
for (int x = 0; x < bmp.Width; x++)
|
||||
{
|
||||
var pixel = bmp.GetPixel(x, y);
|
||||
var color = Math.Min((pixel.R + pixel.G + pixel.B + brightness) * contrast / 300, 255);
|
||||
var color = Math.Min((pixel.R + pixel.G + pixel.B + gamma) * contrast / 300, 255);
|
||||
if (color > 20)
|
||||
SetLedDiagonal(x, y, (byte)color, deltaX, deltaY - (FullRows / 2) - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetBitmapLinear(Bitmap bmp, int contrast = 100, int brightness = 0)
|
||||
private void SetBitmapLinear(Bitmap bmp, int contrast = 100, int gamma = 0)
|
||||
{
|
||||
for (int y = 0; y < bmp.Height; y++)
|
||||
{
|
||||
@@ -366,7 +366,7 @@ namespace GHelper.AnimeMatrix
|
||||
if (x % 2 == y % 2)
|
||||
{
|
||||
var pixel = bmp.GetPixel(x, y);
|
||||
var color = Math.Min((pixel.R + pixel.G + pixel.B + brightness) * contrast / 300, 255);
|
||||
var color = Math.Min((pixel.R + pixel.G + pixel.B + gamma) * contrast / 300, 255);
|
||||
if (color > 20)
|
||||
SetLedPlanar(x / 2, y, (byte)color);
|
||||
}
|
||||
@@ -413,7 +413,7 @@ namespace GHelper.AnimeMatrix
|
||||
Present();
|
||||
|
||||
}
|
||||
public void GenerateFrame(Image image, float zoom = 100, int panX = 0, int panY = 0, InterpolationMode quality = InterpolationMode.Default, int contrast = 100, int brightness = 0)
|
||||
public void GenerateFrame(Image image, float zoom = 100, int panX = 0, int panY = 0, InterpolationMode quality = InterpolationMode.Default, int contrast = 100, int gamma = 0)
|
||||
{
|
||||
int width = MaxColumns / 2 * 6;
|
||||
int height = MaxRows;
|
||||
@@ -440,11 +440,11 @@ namespace GHelper.AnimeMatrix
|
||||
}
|
||||
|
||||
Clear();
|
||||
SetBitmapLinear(bmp, contrast, brightness);
|
||||
SetBitmapLinear(bmp, contrast, gamma);
|
||||
}
|
||||
}
|
||||
|
||||
public void GenerateFrameDiagonal(Image image, float zoom = 100, int panX = 0, int panY = 0, InterpolationMode quality = InterpolationMode.Default, int contrast = 100, int brightness = 0)
|
||||
public void GenerateFrameDiagonal(Image image, float zoom = 100, int panX = 0, int panY = 0, InterpolationMode quality = InterpolationMode.Default, int contrast = 100, int gamma = 0)
|
||||
{
|
||||
int width = MaxRows + FullRows;
|
||||
int height = MaxColumns + FullRows;
|
||||
@@ -471,7 +471,7 @@ namespace GHelper.AnimeMatrix
|
||||
}
|
||||
|
||||
Clear();
|
||||
SetBitmapDiagonal(bmp, -panX, height + panY, contrast, brightness);
|
||||
SetBitmapDiagonal(bmp, -panX, height + panY, contrast, gamma);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
104
app/Matrix.Designer.cs
generated
104
app/Matrix.Designer.cs
generated
@@ -35,10 +35,10 @@
|
||||
panelMain = new Panel();
|
||||
panelButtons = new Panel();
|
||||
buttonReset = new UI.RButton();
|
||||
panelBrightness = new Panel();
|
||||
labelBrightness = new Label();
|
||||
labelBrightnessTitle = new Label();
|
||||
trackBrightness = new TrackBar();
|
||||
panelGamma = new Panel();
|
||||
labelGamma = new Label();
|
||||
labelGammaTitle = new Label();
|
||||
trackGamma = new TrackBar();
|
||||
panelContrast = new Panel();
|
||||
labelContrast = new Label();
|
||||
labelContrastTitle = new Label();
|
||||
@@ -57,8 +57,8 @@
|
||||
panelPicture.SuspendLayout();
|
||||
panelMain.SuspendLayout();
|
||||
panelButtons.SuspendLayout();
|
||||
panelBrightness.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackBrightness).BeginInit();
|
||||
panelGamma.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackGamma).BeginInit();
|
||||
panelContrast.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackContrast).BeginInit();
|
||||
panelRotation.SuspendLayout();
|
||||
@@ -123,7 +123,7 @@
|
||||
//
|
||||
panelMain.AutoSize = true;
|
||||
panelMain.Controls.Add(panelButtons);
|
||||
panelMain.Controls.Add(panelBrightness);
|
||||
panelMain.Controls.Add(panelGamma);
|
||||
panelMain.Controls.Add(panelContrast);
|
||||
panelMain.Controls.Add(panelRotation);
|
||||
panelMain.Controls.Add(panelScaling);
|
||||
@@ -164,51 +164,51 @@
|
||||
buttonReset.TextImageRelation = TextImageRelation.ImageBeforeText;
|
||||
buttonReset.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// panelBrightness
|
||||
// panelGamma
|
||||
//
|
||||
panelBrightness.AutoSize = true;
|
||||
panelBrightness.Controls.Add(labelBrightness);
|
||||
panelBrightness.Controls.Add(labelBrightnessTitle);
|
||||
panelBrightness.Controls.Add(trackBrightness);
|
||||
panelBrightness.Dock = DockStyle.Top;
|
||||
panelBrightness.Location = new Point(0, 865);
|
||||
panelBrightness.Name = "panelBrightness";
|
||||
panelBrightness.Size = new Size(834, 145);
|
||||
panelBrightness.TabIndex = 7;
|
||||
panelGamma.AutoSize = true;
|
||||
panelGamma.Controls.Add(labelGamma);
|
||||
panelGamma.Controls.Add(labelGammaTitle);
|
||||
panelGamma.Controls.Add(trackGamma);
|
||||
panelGamma.Dock = DockStyle.Top;
|
||||
panelGamma.Location = new Point(0, 865);
|
||||
panelGamma.Name = "panelGamma";
|
||||
panelGamma.Size = new Size(834, 145);
|
||||
panelGamma.TabIndex = 7;
|
||||
//
|
||||
// labelBrightness
|
||||
// labelGamma
|
||||
//
|
||||
labelBrightness.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelBrightness.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
labelBrightness.Location = new Point(673, 17);
|
||||
labelBrightness.Name = "labelBrightness";
|
||||
labelBrightness.Size = new Size(125, 32);
|
||||
labelBrightness.TabIndex = 4;
|
||||
labelBrightness.Text = "Brightness";
|
||||
labelBrightness.TextAlign = ContentAlignment.TopRight;
|
||||
labelGamma.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelGamma.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
labelGamma.Location = new Point(673, 17);
|
||||
labelGamma.Name = "labelGamma";
|
||||
labelGamma.Size = new Size(125, 32);
|
||||
labelGamma.TabIndex = 4;
|
||||
labelGamma.Text = "Brightness";
|
||||
labelGamma.TextAlign = ContentAlignment.TopRight;
|
||||
//
|
||||
// labelBrightnessTitle
|
||||
// labelGammaTitle
|
||||
//
|
||||
labelBrightnessTitle.AutoSize = true;
|
||||
labelBrightnessTitle.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelBrightnessTitle.Location = new Point(16, 17);
|
||||
labelBrightnessTitle.Name = "labelBrightnessTitle";
|
||||
labelBrightnessTitle.Size = new Size(134, 32);
|
||||
labelBrightnessTitle.TabIndex = 3;
|
||||
labelBrightnessTitle.Text = "Brightness";
|
||||
labelGammaTitle.AutoSize = true;
|
||||
labelGammaTitle.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelGammaTitle.Location = new Point(16, 17);
|
||||
labelGammaTitle.Name = "labelGammaTitle";
|
||||
labelGammaTitle.Size = new Size(134, 32);
|
||||
labelGammaTitle.TabIndex = 3;
|
||||
labelGammaTitle.Text = "Brightness";
|
||||
//
|
||||
// trackBrightness
|
||||
// trackGamma
|
||||
//
|
||||
trackBrightness.LargeChange = 50;
|
||||
trackBrightness.Location = new Point(16, 52);
|
||||
trackBrightness.Maximum = 100;
|
||||
trackBrightness.Minimum = -100;
|
||||
trackBrightness.Name = "trackBrightness";
|
||||
trackBrightness.Size = new Size(782, 90);
|
||||
trackBrightness.SmallChange = 10;
|
||||
trackBrightness.TabIndex = 2;
|
||||
trackBrightness.TickFrequency = 20;
|
||||
trackBrightness.TickStyle = TickStyle.TopLeft;
|
||||
trackGamma.LargeChange = 50;
|
||||
trackGamma.Location = new Point(16, 52);
|
||||
trackGamma.Maximum = 100;
|
||||
trackGamma.Minimum = -100;
|
||||
trackGamma.Name = "trackGamma";
|
||||
trackGamma.Size = new Size(782, 90);
|
||||
trackGamma.SmallChange = 10;
|
||||
trackGamma.TabIndex = 2;
|
||||
trackGamma.TickFrequency = 20;
|
||||
trackGamma.TickStyle = TickStyle.TopLeft;
|
||||
//
|
||||
// panelContrast
|
||||
//
|
||||
@@ -379,9 +379,9 @@
|
||||
panelMain.ResumeLayout(false);
|
||||
panelMain.PerformLayout();
|
||||
panelButtons.ResumeLayout(false);
|
||||
panelBrightness.ResumeLayout(false);
|
||||
panelBrightness.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackBrightness).EndInit();
|
||||
panelGamma.ResumeLayout(false);
|
||||
panelGamma.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackGamma).EndInit();
|
||||
panelContrast.ResumeLayout(false);
|
||||
panelContrast.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackContrast).EndInit();
|
||||
@@ -417,9 +417,9 @@
|
||||
private Label labelContrast;
|
||||
private Label labelContrastTitle;
|
||||
private TrackBar trackContrast;
|
||||
private Panel panelBrightness;
|
||||
private Label labelBrightness;
|
||||
private Label labelBrightnessTitle;
|
||||
private TrackBar trackBrightness;
|
||||
private Panel panelGamma;
|
||||
private Label labelGamma;
|
||||
private Label labelGammaTitle;
|
||||
private TrackBar trackGamma;
|
||||
}
|
||||
}
|
||||
@@ -47,13 +47,13 @@ namespace GHelper
|
||||
trackZoom.ValueChanged += TrackZoom_Changed;
|
||||
trackZoom.Value = Math.Min(trackZoom.Maximum, AppConfig.Get("matrix_zoom", 100));
|
||||
|
||||
trackContrast.MouseUp += TrackContrast_MouseUp;
|
||||
trackContrast.MouseUp += TrackMatrix_MouseUp;
|
||||
trackContrast.ValueChanged += TrackMatrix_ValueChanged;
|
||||
trackContrast.Value = Math.Min(trackContrast.Maximum, AppConfig.Get("matrix_contrast", 100));
|
||||
|
||||
trackBrightness.MouseUp += TrackBrightness_MouseUp;
|
||||
trackBrightness.ValueChanged += TrackMatrix_ValueChanged;
|
||||
trackBrightness.Value = Math.Min(trackBrightness.Maximum, AppConfig.Get("matrix_brightness", 0));
|
||||
trackGamma.MouseUp += TrackMatrix_MouseUp;
|
||||
trackGamma.ValueChanged += TrackMatrix_ValueChanged;
|
||||
trackGamma.Value = Math.Min(trackGamma.Maximum, AppConfig.Get("matrix_gamma", 0));
|
||||
|
||||
VisualiseMatrix();
|
||||
|
||||
@@ -76,15 +76,10 @@ namespace GHelper
|
||||
VisualiseMatrix();
|
||||
}
|
||||
|
||||
private void TrackContrast_MouseUp(object? sender, MouseEventArgs e)
|
||||
private void TrackMatrix_MouseUp(object? sender, MouseEventArgs e)
|
||||
{
|
||||
AppConfig.Set("matrix_contrast", trackContrast.Value);
|
||||
SetMatrixPicture();
|
||||
}
|
||||
|
||||
private void TrackBrightness_MouseUp(object? sender, MouseEventArgs e)
|
||||
{
|
||||
AppConfig.Set("matrix_brightness", trackBrightness.Value);
|
||||
AppConfig.Set("matrix_gamma", trackGamma.Value);
|
||||
SetMatrixPicture();
|
||||
}
|
||||
|
||||
@@ -115,12 +110,12 @@ namespace GHelper
|
||||
{
|
||||
labelZoom.Text = trackZoom.Value + "%";
|
||||
labelContrast.Text = trackContrast.Value + "%";
|
||||
labelBrightness.Text = trackBrightness.Value + "%";
|
||||
labelGamma.Text = trackGamma.Value + "%";
|
||||
}
|
||||
|
||||
private void ButtonReset_Click(object? sender, EventArgs e)
|
||||
{
|
||||
AppConfig.Set("matrix_brightness", 0);
|
||||
AppConfig.Set("matrix_gamma", 0);
|
||||
AppConfig.Set("matrix_contrast", 100);
|
||||
AppConfig.Set("matrix_zoom", 100);
|
||||
AppConfig.Set("matrix_x", 0);
|
||||
@@ -128,7 +123,7 @@ namespace GHelper
|
||||
|
||||
trackZoom.Value = 100;
|
||||
trackContrast.Value = 100;
|
||||
trackBrightness.Value = 0;
|
||||
trackGamma.Value = 0;
|
||||
|
||||
SetMatrixPicture();
|
||||
|
||||
|
||||
@@ -1097,7 +1097,7 @@ namespace GHelper
|
||||
checkMatrixLid.Visible = true;
|
||||
}
|
||||
|
||||
comboMatrix.SelectedIndex = Math.Min(AppConfig.Get("matrix_brightness", 0), comboMatrix.Items.Count - 1);
|
||||
comboMatrix.SelectedIndex = Math.Max(0, Math.Min(AppConfig.Get("matrix_brightness", 0), comboMatrix.Items.Count - 1));
|
||||
comboMatrixRunning.SelectedIndex = Math.Min(AppConfig.Get("matrix_running", 0), comboMatrixRunning.Items.Count - 1);
|
||||
comboInterval.SelectedIndex = Math.Min(AppConfig.Get("matrix_interval", 0), comboInterval.Items.Count - 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user