diff --git a/Matrix App/Defaults.cs b/Matrix App/Defaults.cs index ecd9b33..5c19a2f 100644 --- a/Matrix App/Defaults.cs +++ b/Matrix App/Defaults.cs @@ -30,7 +30,7 @@ namespace Matrix_App public const int FilterPreviewWidth = 32; public const int FilterPreviewHeight = 32; - public const int ArduinoSuccessByte = 21; + public const int ArduinoSuccessByte = 75; public const int ArduinoCommandQueueSize = 2; public const int ArduinoReceiveBufferSize = 1 + 1 + 1 + MatrixLimitedWidth * MatrixLimitedHeight; diff --git a/Matrix App/PregeneratedMods/MatrixGifGenerator.cs b/Matrix App/PregeneratedMods/MatrixGifGenerator.cs index 35fcda0..5ecfc79 100644 --- a/Matrix App/PregeneratedMods/MatrixGifGenerator.cs +++ b/Matrix App/PregeneratedMods/MatrixGifGenerator.cs @@ -119,7 +119,13 @@ namespace Matrix_App Text = FieldWidgets.GetBetterFieldName(generator.GetType().Name) }; button.Width = anchor.ClientSize.Width - button.Margin.Right - button.Margin.Left; - button.Click += (sender, e) => OpenGeneratorUi(generator, matrix); + button.Click += (sender, e) => + { + lock (matrix) + { + OpenGeneratorUi(generator, matrix); + } + }; button.Image = CreateSnapshot(generator); button.TextImageRelation = TextImageRelation.ImageBeforeText; button.TextAlign = ContentAlignment.MiddleRight; diff --git a/Matrix App/adds/PortCommandQueue.cs b/Matrix App/adds/PortCommandQueue.cs index 383f6e1..1dd929d 100644 --- a/Matrix App/adds/PortCommandQueue.cs +++ b/Matrix App/adds/PortCommandQueue.cs @@ -72,11 +72,7 @@ namespace Matrix_App } catch (ThreadInterruptedException) { Thread.CurrentThread.Interrupt(); - } - catch (Exception) - { - // omit - } + } } [SecurityPermissionAttribute(SecurityAction.Demand, ControlThread = true)] diff --git a/Matrix App/bin/Debug/netcoreapp3.1/Matrix App.dll b/Matrix App/bin/Debug/netcoreapp3.1/Matrix App.dll index 8f876ca..84515e2 100644 Binary files a/Matrix App/bin/Debug/netcoreapp3.1/Matrix App.dll and b/Matrix App/bin/Debug/netcoreapp3.1/Matrix App.dll differ diff --git a/Matrix App/bin/Debug/netcoreapp3.1/Matrix App.pdb b/Matrix App/bin/Debug/netcoreapp3.1/Matrix App.pdb index b3193b2..9716389 100644 Binary files a/Matrix App/bin/Debug/netcoreapp3.1/Matrix App.pdb and b/Matrix App/bin/Debug/netcoreapp3.1/Matrix App.pdb differ diff --git a/Matrix App/forms/MatrixDesigner.cs b/Matrix App/forms/MatrixDesigner.cs index 64dea05..6c5bad6 100644 --- a/Matrix App/forms/MatrixDesigner.cs +++ b/Matrix App/forms/MatrixDesigner.cs @@ -524,8 +524,8 @@ namespace Matrix_App matrixView.SetPixelNoRefresh(x, y, pixel); - gifBuffer[i][index * 3] = pixel.G; - gifBuffer[i][index * 3 + 1] = pixel.R; + gifBuffer[i][index * 3 + 0] = pixel.R; + gifBuffer[i][index * 3 + 1] = pixel.G; gifBuffer[i][index * 3 + 2] = pixel.B; } } @@ -547,8 +547,8 @@ namespace Matrix_App int index = x + y * bitmap.Width; - gifBuffer[Timeline.Value][index * 3] = pixel.G; - gifBuffer[Timeline.Value][index * 3 + 1] = pixel.R; + gifBuffer[Timeline.Value][index * 3 + 0] = pixel.R; + gifBuffer[Timeline.Value][index * 3 + 1] = pixel.G; gifBuffer[Timeline.Value][index * 3 + 2] = pixel.B; } } @@ -633,8 +633,8 @@ namespace Matrix_App var color = matrixView.GetPixel(x, y); - gifBuffer[Timeline.Value][tmp] = color.G; - gifBuffer[Timeline.Value][tmp + 1] = color.R; + gifBuffer[Timeline.Value][tmp + 0] = color.R; + gifBuffer[Timeline.Value][tmp + 1] = color.G; gifBuffer[Timeline.Value][tmp + 2] = color.B; } } @@ -756,13 +756,27 @@ namespace Matrix_App int width = data[0]; int height = data[1]; - this.matrixWidth.Value = width; - this.matrixHeight.Value = height; - - for (var x = 0; x < width * height * 3; x++) + matrixWidth.Value = width; + matrixHeight.Value = height; + + for (var y = 0; y < height; y++) { - gifBuffer[0][x] = data[2 + x]; + for (var x = 0; x < width; x++) + { + var i0 = x * 3 + y * width * 3; + + var x1 = height - y - 1; + var y1 = width - x - 1; + + var i1 = x1 * 3 + y1 * width * 3; + + // degamma + gifBuffer[0][i0 + 0] = (byte) MathF.Sqrt(data[i1 + 0 + 2] / 258.0f * 65536.0f); + gifBuffer[0][i0 + 1] = (byte) MathF.Sqrt(data[i1 + 1 + 2] / 258.0f * 65536.0f); + gifBuffer[0][i0 + 2] = (byte) MathF.Sqrt(data[i1 + 2 + 2] / 258.0f * 65536.0f); + } } + Timeline.Value = 1; Timeline.Value = 0; } @@ -835,7 +849,6 @@ namespace Matrix_App gammaImage[i0 + 2] = rgbImageData[i1 + 2]; } } - for (var i = 0; i < rgbImageData.Length; i++) { diff --git a/Matrix App/obj/Debug/netcoreapp3.1/Matrix App.dll b/Matrix App/obj/Debug/netcoreapp3.1/Matrix App.dll index 8f876ca..84515e2 100644 Binary files a/Matrix App/obj/Debug/netcoreapp3.1/Matrix App.dll and b/Matrix App/obj/Debug/netcoreapp3.1/Matrix App.dll differ diff --git a/Matrix App/obj/Debug/netcoreapp3.1/Matrix App.pdb b/Matrix App/obj/Debug/netcoreapp3.1/Matrix App.pdb index b3193b2..9716389 100644 Binary files a/Matrix App/obj/Debug/netcoreapp3.1/Matrix App.pdb and b/Matrix App/obj/Debug/netcoreapp3.1/Matrix App.pdb differ