mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Anime Matrix Brightness https://github.com/seerge/g-helper/issues/2486
This commit is contained in:
@@ -465,6 +465,7 @@ namespace GHelper.AnimeMatrix
|
|||||||
|
|
||||||
int matrixZoom = AppConfig.Get("matrix_zoom", 100);
|
int matrixZoom = AppConfig.Get("matrix_zoom", 100);
|
||||||
int matrixContrast = AppConfig.Get("matrix_contrast", 100);
|
int matrixContrast = AppConfig.Get("matrix_contrast", 100);
|
||||||
|
int matrixBrightness = AppConfig.Get("matrix_brightness", 0);
|
||||||
|
|
||||||
int matrixSpeed = AppConfig.Get("matrix_speed", 50);
|
int matrixSpeed = AppConfig.Get("matrix_speed", 50);
|
||||||
|
|
||||||
@@ -486,9 +487,9 @@ namespace GHelper.AnimeMatrix
|
|||||||
image.SelectActiveFrame(dimension, i);
|
image.SelectActiveFrame(dimension, i);
|
||||||
|
|
||||||
if (rotation == MatrixRotation.Planar)
|
if (rotation == MatrixRotation.Planar)
|
||||||
deviceMatrix.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast);
|
deviceMatrix.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast, matrixBrightness);
|
||||||
else
|
else
|
||||||
deviceMatrix.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast);
|
deviceMatrix.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast, matrixBrightness);
|
||||||
|
|
||||||
deviceMatrix.AddFrame();
|
deviceMatrix.AddFrame();
|
||||||
}
|
}
|
||||||
@@ -503,9 +504,9 @@ namespace GHelper.AnimeMatrix
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (rotation == MatrixRotation.Planar)
|
if (rotation == MatrixRotation.Planar)
|
||||||
deviceMatrix.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast);
|
deviceMatrix.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast, matrixBrightness);
|
||||||
else
|
else
|
||||||
deviceMatrix.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast);
|
deviceMatrix.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast, matrixBrightness);
|
||||||
|
|
||||||
deviceMatrix.Present();
|
deviceMatrix.Present();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -344,21 +344,21 @@ namespace GHelper.AnimeMatrix
|
|||||||
if (present) Present();
|
if (present) Present();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetBitmapDiagonal(Bitmap bmp, int deltaX = 0, int deltaY = 0, int contrast = 100)
|
private void SetBitmapDiagonal(Bitmap bmp, int deltaX = 0, int deltaY = 0, int contrast = 100, int brightness = 0)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < bmp.Height; y++)
|
for (int y = 0; y < bmp.Height; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < bmp.Width; x++)
|
for (int x = 0; x < bmp.Width; x++)
|
||||||
{
|
{
|
||||||
var pixel = bmp.GetPixel(x, y);
|
var pixel = bmp.GetPixel(x, y);
|
||||||
var color = Math.Min((pixel.R + pixel.G + pixel.B) * contrast / 300, 255);
|
var color = Math.Min((pixel.R + pixel.G + pixel.B + brightness) * contrast / 300, 255);
|
||||||
if (color > 20)
|
if (color > 20)
|
||||||
SetLedDiagonal(x, y, (byte)color, deltaX, deltaY - (FullRows / 2) - 1);
|
SetLedDiagonal(x, y, (byte)color, deltaX, deltaY - (FullRows / 2) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetBitmapLinear(Bitmap bmp, int contrast = 100)
|
private void SetBitmapLinear(Bitmap bmp, int contrast = 100, int brightness = 0)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < bmp.Height; y++)
|
for (int y = 0; y < bmp.Height; y++)
|
||||||
{
|
{
|
||||||
@@ -366,7 +366,7 @@ namespace GHelper.AnimeMatrix
|
|||||||
if (x % 2 == y % 2)
|
if (x % 2 == y % 2)
|
||||||
{
|
{
|
||||||
var pixel = bmp.GetPixel(x, y);
|
var pixel = bmp.GetPixel(x, y);
|
||||||
var color = Math.Min((pixel.R + pixel.G + pixel.B) * contrast / 300, 255);
|
var color = Math.Min((pixel.R + pixel.G + pixel.B + brightness) * contrast / 300, 255);
|
||||||
if (color > 20)
|
if (color > 20)
|
||||||
SetLedPlanar(x / 2, y, (byte)color);
|
SetLedPlanar(x / 2, y, (byte)color);
|
||||||
}
|
}
|
||||||
@@ -413,7 +413,7 @@ namespace GHelper.AnimeMatrix
|
|||||||
Present();
|
Present();
|
||||||
|
|
||||||
}
|
}
|
||||||
public void GenerateFrame(Image image, float zoom = 100, int panX = 0, int panY = 0, InterpolationMode quality = InterpolationMode.Default, int contrast = 100)
|
public void GenerateFrame(Image image, float zoom = 100, int panX = 0, int panY = 0, InterpolationMode quality = InterpolationMode.Default, int contrast = 100, int brightness = 0)
|
||||||
{
|
{
|
||||||
int width = MaxColumns / 2 * 6;
|
int width = MaxColumns / 2 * 6;
|
||||||
int height = MaxRows;
|
int height = MaxRows;
|
||||||
@@ -440,11 +440,11 @@ namespace GHelper.AnimeMatrix
|
|||||||
}
|
}
|
||||||
|
|
||||||
Clear();
|
Clear();
|
||||||
SetBitmapLinear(bmp, contrast);
|
SetBitmapLinear(bmp, contrast, brightness);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateFrameDiagonal(Image image, float zoom = 100, int panX = 0, int panY = 0, InterpolationMode quality = InterpolationMode.Default, int contrast = 100)
|
public void GenerateFrameDiagonal(Image image, float zoom = 100, int panX = 0, int panY = 0, InterpolationMode quality = InterpolationMode.Default, int contrast = 100, int brightness = 0)
|
||||||
{
|
{
|
||||||
int width = MaxRows + FullRows;
|
int width = MaxRows + FullRows;
|
||||||
int height = MaxColumns + FullRows;
|
int height = MaxColumns + FullRows;
|
||||||
@@ -471,7 +471,7 @@ namespace GHelper.AnimeMatrix
|
|||||||
}
|
}
|
||||||
|
|
||||||
Clear();
|
Clear();
|
||||||
SetBitmapDiagonal(bmp, -panX, height + panY, contrast);
|
SetBitmapDiagonal(bmp, -panX, height + panY, contrast, brightness);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
70
app/Matrix.Designer.cs
generated
70
app/Matrix.Designer.cs
generated
@@ -35,6 +35,10 @@
|
|||||||
panelMain = new Panel();
|
panelMain = new Panel();
|
||||||
panelButtons = new Panel();
|
panelButtons = new Panel();
|
||||||
buttonReset = new UI.RButton();
|
buttonReset = new UI.RButton();
|
||||||
|
panelBrightness = new Panel();
|
||||||
|
labelBrightness = new Label();
|
||||||
|
labelBrightnessTitle = new Label();
|
||||||
|
trackBrightness = new TrackBar();
|
||||||
panelContrast = new Panel();
|
panelContrast = new Panel();
|
||||||
labelContrast = new Label();
|
labelContrast = new Label();
|
||||||
labelContrastTitle = new Label();
|
labelContrastTitle = new Label();
|
||||||
@@ -53,6 +57,8 @@
|
|||||||
panelPicture.SuspendLayout();
|
panelPicture.SuspendLayout();
|
||||||
panelMain.SuspendLayout();
|
panelMain.SuspendLayout();
|
||||||
panelButtons.SuspendLayout();
|
panelButtons.SuspendLayout();
|
||||||
|
panelBrightness.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)trackBrightness).BeginInit();
|
||||||
panelContrast.SuspendLayout();
|
panelContrast.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)trackContrast).BeginInit();
|
((System.ComponentModel.ISupportInitialize)trackContrast).BeginInit();
|
||||||
panelRotation.SuspendLayout();
|
panelRotation.SuspendLayout();
|
||||||
@@ -117,6 +123,7 @@
|
|||||||
//
|
//
|
||||||
panelMain.AutoSize = true;
|
panelMain.AutoSize = true;
|
||||||
panelMain.Controls.Add(panelButtons);
|
panelMain.Controls.Add(panelButtons);
|
||||||
|
panelMain.Controls.Add(panelBrightness);
|
||||||
panelMain.Controls.Add(panelContrast);
|
panelMain.Controls.Add(panelContrast);
|
||||||
panelMain.Controls.Add(panelRotation);
|
panelMain.Controls.Add(panelRotation);
|
||||||
panelMain.Controls.Add(panelScaling);
|
panelMain.Controls.Add(panelScaling);
|
||||||
@@ -125,7 +132,7 @@
|
|||||||
panelMain.Dock = DockStyle.Top;
|
panelMain.Dock = DockStyle.Top;
|
||||||
panelMain.Location = new Point(20, 20);
|
panelMain.Location = new Point(20, 20);
|
||||||
panelMain.Name = "panelMain";
|
panelMain.Name = "panelMain";
|
||||||
panelMain.Size = new Size(834, 959);
|
panelMain.Size = new Size(834, 1104);
|
||||||
panelMain.TabIndex = 5;
|
panelMain.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// panelButtons
|
// panelButtons
|
||||||
@@ -133,7 +140,7 @@
|
|||||||
panelButtons.Controls.Add(buttonReset);
|
panelButtons.Controls.Add(buttonReset);
|
||||||
panelButtons.Controls.Add(buttonPicture);
|
panelButtons.Controls.Add(buttonPicture);
|
||||||
panelButtons.Dock = DockStyle.Top;
|
panelButtons.Dock = DockStyle.Top;
|
||||||
panelButtons.Location = new Point(0, 865);
|
panelButtons.Location = new Point(0, 1010);
|
||||||
panelButtons.Name = "panelButtons";
|
panelButtons.Name = "panelButtons";
|
||||||
panelButtons.Size = new Size(834, 94);
|
panelButtons.Size = new Size(834, 94);
|
||||||
panelButtons.TabIndex = 6;
|
panelButtons.TabIndex = 6;
|
||||||
@@ -157,6 +164,52 @@
|
|||||||
buttonReset.TextImageRelation = TextImageRelation.ImageBeforeText;
|
buttonReset.TextImageRelation = TextImageRelation.ImageBeforeText;
|
||||||
buttonReset.UseVisualStyleBackColor = false;
|
buttonReset.UseVisualStyleBackColor = false;
|
||||||
//
|
//
|
||||||
|
// panelBrightness
|
||||||
|
//
|
||||||
|
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;
|
||||||
|
//
|
||||||
|
// labelBrightness
|
||||||
|
//
|
||||||
|
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;
|
||||||
|
//
|
||||||
|
// labelBrightnessTitle
|
||||||
|
//
|
||||||
|
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";
|
||||||
|
//
|
||||||
|
// trackBrightness
|
||||||
|
//
|
||||||
|
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;
|
||||||
|
//
|
||||||
// panelContrast
|
// panelContrast
|
||||||
//
|
//
|
||||||
panelContrast.AutoSize = true;
|
panelContrast.AutoSize = true;
|
||||||
@@ -172,13 +225,13 @@
|
|||||||
// labelContrast
|
// labelContrast
|
||||||
//
|
//
|
||||||
labelContrast.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
labelContrast.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
labelContrast.AutoSize = true;
|
|
||||||
labelContrast.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
labelContrast.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
labelContrast.Location = new Point(705, 17);
|
labelContrast.Location = new Point(701, 17);
|
||||||
labelContrast.Name = "labelContrast";
|
labelContrast.Name = "labelContrast";
|
||||||
labelContrast.Size = new Size(103, 32);
|
labelContrast.Size = new Size(103, 32);
|
||||||
labelContrast.TabIndex = 4;
|
labelContrast.TabIndex = 4;
|
||||||
labelContrast.Text = "Contrast";
|
labelContrast.Text = "Contrast";
|
||||||
|
labelContrast.TextAlign = ContentAlignment.TopRight;
|
||||||
//
|
//
|
||||||
// labelContrastTitle
|
// labelContrastTitle
|
||||||
//
|
//
|
||||||
@@ -310,7 +363,7 @@
|
|||||||
AutoScaleDimensions = new SizeF(192F, 192F);
|
AutoScaleDimensions = new SizeF(192F, 192F);
|
||||||
AutoScaleMode = AutoScaleMode.Dpi;
|
AutoScaleMode = AutoScaleMode.Dpi;
|
||||||
AutoSize = true;
|
AutoSize = true;
|
||||||
ClientSize = new Size(874, 1006);
|
ClientSize = new Size(874, 1142);
|
||||||
Controls.Add(panelMain);
|
Controls.Add(panelMain);
|
||||||
MaximizeBox = false;
|
MaximizeBox = false;
|
||||||
MinimizeBox = false;
|
MinimizeBox = false;
|
||||||
@@ -326,6 +379,9 @@
|
|||||||
panelMain.ResumeLayout(false);
|
panelMain.ResumeLayout(false);
|
||||||
panelMain.PerformLayout();
|
panelMain.PerformLayout();
|
||||||
panelButtons.ResumeLayout(false);
|
panelButtons.ResumeLayout(false);
|
||||||
|
panelBrightness.ResumeLayout(false);
|
||||||
|
panelBrightness.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)trackBrightness).EndInit();
|
||||||
panelContrast.ResumeLayout(false);
|
panelContrast.ResumeLayout(false);
|
||||||
panelContrast.PerformLayout();
|
panelContrast.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)trackContrast).EndInit();
|
((System.ComponentModel.ISupportInitialize)trackContrast).EndInit();
|
||||||
@@ -361,5 +417,9 @@
|
|||||||
private Label labelContrast;
|
private Label labelContrast;
|
||||||
private Label labelContrastTitle;
|
private Label labelContrastTitle;
|
||||||
private TrackBar trackContrast;
|
private TrackBar trackContrast;
|
||||||
|
private Panel panelBrightness;
|
||||||
|
private Label labelBrightness;
|
||||||
|
private Label labelBrightnessTitle;
|
||||||
|
private TrackBar trackBrightness;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,10 +47,14 @@ namespace GHelper
|
|||||||
trackZoom.ValueChanged += TrackZoom_Changed;
|
trackZoom.ValueChanged += TrackZoom_Changed;
|
||||||
trackZoom.Value = Math.Min(trackZoom.Maximum, AppConfig.Get("matrix_zoom", 100));
|
trackZoom.Value = Math.Min(trackZoom.Maximum, AppConfig.Get("matrix_zoom", 100));
|
||||||
|
|
||||||
trackContrast.MouseUp += TrackContrast_MouseUp; ;
|
trackContrast.MouseUp += TrackContrast_MouseUp;
|
||||||
trackContrast.ValueChanged += TrackContrast_ValueChanged; ;
|
trackContrast.ValueChanged += TrackMatrix_ValueChanged;
|
||||||
trackContrast.Value = Math.Min(trackContrast.Maximum, AppConfig.Get("matrix_contrast", 100));
|
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));
|
||||||
|
|
||||||
VisualiseMatrix();
|
VisualiseMatrix();
|
||||||
|
|
||||||
comboScaling.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboScaling.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
@@ -67,7 +71,7 @@ namespace GHelper
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TrackContrast_ValueChanged(object? sender, EventArgs e)
|
private void TrackMatrix_ValueChanged(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
VisualiseMatrix();
|
VisualiseMatrix();
|
||||||
}
|
}
|
||||||
@@ -78,6 +82,13 @@ namespace GHelper
|
|||||||
SetMatrixPicture();
|
SetMatrixPicture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void TrackBrightness_MouseUp(object? sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
AppConfig.Set("matrix_brightness", trackBrightness.Value);
|
||||||
|
SetMatrixPicture();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ComboRotation_SelectedValueChanged(object? sender, EventArgs e)
|
private void ComboRotation_SelectedValueChanged(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
AppConfig.Set("matrix_rotation", comboRotation.SelectedIndex);
|
AppConfig.Set("matrix_rotation", comboRotation.SelectedIndex);
|
||||||
@@ -104,6 +115,7 @@ namespace GHelper
|
|||||||
{
|
{
|
||||||
labelZoom.Text = trackZoom.Value + "%";
|
labelZoom.Text = trackZoom.Value + "%";
|
||||||
labelContrast.Text = trackContrast.Value + "%";
|
labelContrast.Text = trackContrast.Value + "%";
|
||||||
|
labelBrightness.Text = trackBrightness.Value + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonReset_Click(object? sender, EventArgs e)
|
private void ButtonReset_Click(object? sender, EventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user