diff --git a/app/AnimeMatrix/AniMatrixControl.cs b/app/AnimeMatrix/AniMatrixControl.cs index 134ce6ae..025f0f53 100644 --- a/app/AnimeMatrix/AniMatrixControl.cs +++ b/app/AnimeMatrix/AniMatrixControl.cs @@ -347,7 +347,10 @@ namespace GHelper.AnimeMatrix int matrixX = AppConfig.Get("matrix_x", 0); int matrixY = AppConfig.Get("matrix_y", 0); + int matrixZoom = AppConfig.Get("matrix_zoom", 100); + int matrixContrast = AppConfig.Get("matrix_contrast", 100); + int matrixSpeed = AppConfig.Get("matrix_speed", 50); MatrixRotation rotation = (MatrixRotation)AppConfig.Get("matrix_rotation", 0); @@ -368,9 +371,9 @@ namespace GHelper.AnimeMatrix image.SelectActiveFrame(dimension, i); if (rotation == MatrixRotation.Planar) - device.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality); + device.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast); else - device.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality); + device.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast); device.AddFrame(); } @@ -385,9 +388,9 @@ namespace GHelper.AnimeMatrix else { if (rotation == MatrixRotation.Planar) - device.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality); + device.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast); else - device.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality); + device.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast); device.Present(); } diff --git a/app/AnimeMatrix/AnimeMatrixDevice.cs b/app/AnimeMatrix/AnimeMatrixDevice.cs index 2f3aed44..c6a90ab8 100644 --- a/app/AnimeMatrix/AnimeMatrixDevice.cs +++ b/app/AnimeMatrix/AnimeMatrixDevice.cs @@ -399,21 +399,21 @@ namespace Starlight.AnimeMatrix } - private void SetBitmapDiagonal(Bitmap bmp, int deltaX = 0, int deltaY = 0) + private void SetBitmapDiagonal(Bitmap bmp, int deltaX = 0, int deltaY = 0, int contrast = 100) { for (int y = 0; y < bmp.Height; y++) { for (int x = 0; x < bmp.Width; x++) { var pixel = bmp.GetPixel(x, y); - var color = (pixel.R + pixel.G + pixel.B) / 3; + var color = Math.Min((pixel.R + pixel.G + pixel.B) * contrast / 300, 255); if (color > 20) SetLedDiagonal(x, y, (byte)color, deltaX + (FullRows / 2) + 1, deltaY - (FullRows / 2) - 1); } } } - private void SetBitmapLinear(Bitmap bmp) + private void SetBitmapLinear(Bitmap bmp, int contrast = 100) { for (int y = 0; y < bmp.Height; y++) { @@ -421,7 +421,7 @@ namespace Starlight.AnimeMatrix if (x % 2 == y % 2) { var pixel = bmp.GetPixel(x, y); - var color = (pixel.R + pixel.G + pixel.B) / 3; + var color = Math.Min((pixel.R + pixel.G + pixel.B) * contrast / 300, 255); if (color > 20) SetLedPlanar(x / 2, y, (byte)color); } @@ -468,7 +468,7 @@ namespace Starlight.AnimeMatrix Present(); } - public void GenerateFrame(Image image, float zoom = 100, int panX = 0, int panY = 0, InterpolationMode quality = InterpolationMode.Default) + public void GenerateFrame(Image image, float zoom = 100, int panX = 0, int panY = 0, InterpolationMode quality = InterpolationMode.Default, int contrast = 100) { int width = MaxColumns / 2 * 6; int height = MaxRows; @@ -495,11 +495,11 @@ namespace Starlight.AnimeMatrix } Clear(); - SetBitmapLinear(bmp); + SetBitmapLinear(bmp, contrast); } } - public void GenerateFrameDiagonal(Image image, float zoom = 100, int panX = 0, int panY = 0, InterpolationMode quality = InterpolationMode.Default) + public void GenerateFrameDiagonal(Image image, float zoom = 100, int panX = 0, int panY = 0, InterpolationMode quality = InterpolationMode.Default, int contrast = 100) { int width = MaxRows - FullRows; int height = MaxRows - FullRows*2; @@ -523,7 +523,7 @@ namespace Starlight.AnimeMatrix } Clear(); - SetBitmapDiagonal(bmp, -panX, height + panY); + SetBitmapDiagonal(bmp, -panX, height + panY, contrast); } } diff --git a/app/AppConfig.cs b/app/AppConfig.cs index 5ff5d589..ac436c52 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -428,7 +428,7 @@ public static class AppConfig public static bool IsGPUFixNeeded() { - return ContainsModel("GA402X") || ContainsModel("GV302") || ContainsModel("GV301") || ContainsModel("GZ301") || ContainsModel("FX506") || ContainsModel("GU603") || ContainsModel("GU604"); + return ContainsModel("GA402X") || ContainsModel("GV302") || ContainsModel("GV301") || ContainsModel("GZ301") || ContainsModel("FX506") || ContainsModel("GU603") || ContainsModel("GU604") || ContainsModel("G614J"); } public static bool IsGPUFix() diff --git a/app/Matrix.Designer.cs b/app/Matrix.Designer.cs index fdef8ea7..38418903 100644 --- a/app/Matrix.Designer.cs +++ b/app/Matrix.Designer.cs @@ -35,6 +35,10 @@ panelMain = new Panel(); panelButtons = new Panel(); buttonReset = new UI.RButton(); + panelContrast = new Panel(); + labelContrast = new Label(); + labelContrastTitle = new Label(); + trackContrast = new TrackBar(); panelRotation = new Panel(); comboRotation = new UI.RComboBox(); labelRotation = new Label(); @@ -49,6 +53,8 @@ panelPicture.SuspendLayout(); panelMain.SuspendLayout(); panelButtons.SuspendLayout(); + panelContrast.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)trackContrast).BeginInit(); panelRotation.SuspendLayout(); panelScaling.SuspendLayout(); panelZoom.SuspendLayout(); @@ -111,6 +117,7 @@ // panelMain.AutoSize = true; panelMain.Controls.Add(panelButtons); + panelMain.Controls.Add(panelContrast); panelMain.Controls.Add(panelRotation); panelMain.Controls.Add(panelScaling); panelMain.Controls.Add(panelZoom); @@ -118,7 +125,7 @@ panelMain.Dock = DockStyle.Top; panelMain.Location = new Point(20, 20); panelMain.Name = "panelMain"; - panelMain.Size = new Size(834, 814); + panelMain.Size = new Size(834, 959); panelMain.TabIndex = 5; // // panelButtons @@ -126,7 +133,7 @@ panelButtons.Controls.Add(buttonReset); panelButtons.Controls.Add(buttonPicture); panelButtons.Dock = DockStyle.Top; - panelButtons.Location = new Point(0, 720); + panelButtons.Location = new Point(0, 865); panelButtons.Name = "panelButtons"; panelButtons.Size = new Size(834, 94); panelButtons.TabIndex = 6; @@ -150,6 +157,53 @@ buttonReset.TextImageRelation = TextImageRelation.ImageBeforeText; buttonReset.UseVisualStyleBackColor = false; // + // panelContrast + // + panelContrast.AutoSize = true; + panelContrast.Controls.Add(labelContrast); + panelContrast.Controls.Add(labelContrastTitle); + panelContrast.Controls.Add(trackContrast); + panelContrast.Dock = DockStyle.Top; + panelContrast.Location = new Point(0, 720); + panelContrast.Name = "panelContrast"; + panelContrast.Size = new Size(834, 145); + panelContrast.TabIndex = 6; + // + // labelContrast + // + labelContrast.Anchor = AnchorStyles.Top | AnchorStyles.Right; + labelContrast.AutoSize = true; + labelContrast.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); + labelContrast.Location = new Point(705, 17); + labelContrast.Name = "labelContrast"; + labelContrast.Size = new Size(103, 32); + labelContrast.TabIndex = 4; + labelContrast.Text = "Contrast"; + // + // labelContrastTitle + // + labelContrastTitle.AutoSize = true; + labelContrastTitle.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelContrastTitle.Location = new Point(16, 17); + labelContrastTitle.Name = "labelContrastTitle"; + labelContrastTitle.Size = new Size(111, 32); + labelContrastTitle.TabIndex = 3; + labelContrastTitle.Text = "Contrast"; + // + // trackContrast + // + trackContrast.LargeChange = 50; + trackContrast.Location = new Point(16, 52); + trackContrast.Maximum = 200; + trackContrast.Minimum = 10; + trackContrast.Name = "trackContrast"; + trackContrast.Size = new Size(782, 90); + trackContrast.SmallChange = 10; + trackContrast.TabIndex = 2; + trackContrast.TickFrequency = 20; + trackContrast.TickStyle = TickStyle.TopLeft; + trackContrast.Value = 100; + // // panelRotation // panelRotation.Controls.Add(comboRotation); @@ -256,7 +310,7 @@ AutoScaleDimensions = new SizeF(192F, 192F); AutoScaleMode = AutoScaleMode.Dpi; AutoSize = true; - ClientSize = new Size(874, 978); + ClientSize = new Size(874, 1006); Controls.Add(panelMain); MaximizeBox = false; MinimizeBox = false; @@ -272,6 +326,9 @@ panelMain.ResumeLayout(false); panelMain.PerformLayout(); panelButtons.ResumeLayout(false); + panelContrast.ResumeLayout(false); + panelContrast.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)trackContrast).EndInit(); panelRotation.ResumeLayout(false); panelRotation.PerformLayout(); panelScaling.ResumeLayout(false); @@ -300,5 +357,9 @@ private Panel panelRotation; private UI.RComboBox comboRotation; private Label labelRotation; + private Panel panelContrast; + private Label labelContrast; + private Label labelContrastTitle; + private TrackBar trackContrast; } } \ No newline at end of file diff --git a/app/Matrix.cs b/app/Matrix.cs index 3d21e00e..d62ef5d7 100644 --- a/app/Matrix.cs +++ b/app/Matrix.cs @@ -37,9 +37,13 @@ namespace GHelper trackZoom.MouseUp += TrackZoom_MouseUp; trackZoom.ValueChanged += TrackZoom_Changed; - trackZoom.Value = Math.Min(trackZoom.Maximum, AppConfig.Get("matrix_zoom", 100)); - VisualiseZoom(); + + trackContrast.MouseUp += TrackContrast_MouseUp; ; + trackContrast.ValueChanged += TrackContrast_ValueChanged; ; + trackContrast.Value = Math.Min(trackContrast.Maximum, AppConfig.Get("matrix_contrast", 100)); + + VisualiseMatrix(); comboScaling.DropDownStyle = ComboBoxStyle.DropDownList; comboScaling.SelectedIndex = AppConfig.Get("matrix_quality", 0); @@ -55,6 +59,17 @@ namespace GHelper } + private void TrackContrast_ValueChanged(object? sender, EventArgs e) + { + VisualiseMatrix(); + } + + private void TrackContrast_MouseUp(object? sender, MouseEventArgs e) + { + AppConfig.Set("matrix_contrast", trackContrast.Value); + SetMatrixPicture(); + } + private void ComboRotation_SelectedValueChanged(object? sender, EventArgs e) { AppConfig.Set("matrix_rotation", comboRotation.SelectedIndex); @@ -77,18 +92,21 @@ namespace GHelper GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); } - private void VisualiseZoom() + private void VisualiseMatrix() { labelZoom.Text = trackZoom.Value + "%"; + labelContrast.Text = trackContrast.Value + "%"; } private void ButtonReset_Click(object? sender, EventArgs e) { + AppConfig.Set("matrix_contrast", 100); AppConfig.Set("matrix_zoom", 100); AppConfig.Set("matrix_x", 0); AppConfig.Set("matrix_y", 0); trackZoom.Value = 100; + trackContrast.Value = 100; SetMatrixPicture(); @@ -102,7 +120,7 @@ namespace GHelper private void TrackZoom_Changed(object? sender, EventArgs e) { - VisualiseZoom(); + VisualiseMatrix(); } @@ -195,7 +213,6 @@ namespace GHelper int matrixY = AppConfig.Get("matrix_y", 0); int matrixZoom = AppConfig.Get("matrix_zoom", 100); - float scale = Math.Min((float)panelPicture.Width / (float)width, (float)panelPicture.Height / (float)height) * matrixZoom / 100; pictureMatrix.Width = (int)(width * scale); diff --git a/app/USB/Aura.cs b/app/USB/Aura.cs index 04ceadd2..0999c93b 100644 --- a/app/USB/Aura.cs +++ b/app/USB/Aura.cs @@ -130,11 +130,11 @@ namespace GHelper.USB timer.Elapsed += Timer_Elapsed; isSingleColor = AppConfig.IsSingleColor(); // Mono Color - if (AppConfig.ContainsModel("GA402X") || AppConfig.ContainsModel("GA402N")) + if (AppConfig.ContainsModel("GA402X") || AppConfig.ContainsModel("GA402N") || AppConfig.ContainsModel("GA503R")) { var device = AsusHid.FindDevices(AsusHid.AURA_ID).FirstOrDefault(); if (device is null) return; - Logger.WriteLine($"GA402: {device.ReleaseNumberBcd} {device.ReleaseNumber}"); + Logger.WriteLine($"USB Version: {device.ReleaseNumberBcd} {device.ReleaseNumber}"); if (device.ReleaseNumberBcd >= 22 && device.ReleaseNumberBcd <= 25) isSingleColor = true; } }