diff --git a/ApplicationView/MainApplicationWidget.cs b/ApplicationView/MainApplicationWidget.cs index 9829c8be2..2118df8b2 100644 --- a/ApplicationView/MainApplicationWidget.cs +++ b/ApplicationView/MainApplicationWidget.cs @@ -29,7 +29,6 @@ either expressed or implied, of the FreeBSD Project. using MatterHackers.Agg; using MatterHackers.Agg.UI; -using MatterHackers.GuiAutomation; using MatterHackers.MatterControl.PrintLibrary; using MatterHackers.MatterControl.PrintLibrary.Provider; using MatterHackers.MatterControl.PrintQueue; @@ -67,18 +66,6 @@ namespace MatterHackers.MatterControl private bool topIsHidden = false; - bool firstDraw = true; - public override void OnDraw(Graphics2D graphics2D) - { - if (firstDraw) - { - PerformanceTests.ReportDrawTimeWhileSwitching(this, "Library Tab", "Controls Tab", .1); - firstDraw = false; - } - - base.OnDraw(graphics2D); - } - public override void HideTopContainer() { if (!topIsHidden) @@ -199,29 +186,6 @@ namespace MatterHackers.MatterControl { } - bool firstDraw = true; - public override void OnDraw(Graphics2D graphics2D) - { - if (firstDraw) - { - //PerformanceTests.ReportDrawTimeWhileSwitching(this, "Library Tab", "History Tab", .1); - - string[] clickThings = new string[] - { - "History Tab", - "Queue Tab", - "Library Tab", - "History Tab", - }; - //PerformanceTests.ClickStuff(this, clickThings); - - - firstDraw = false; - } - - base.OnDraw(graphics2D); - } - public override void AddElements() { Stopwatch timer = Stopwatch.StartNew(); diff --git a/CustomWidgets/PartThumbnailWidget.cs b/CustomWidgets/PartThumbnailWidget.cs index dcf78ab74..07171e000 100644 --- a/CustomWidgets/PartThumbnailWidget.cs +++ b/CustomWidgets/PartThumbnailWidget.cs @@ -310,6 +310,9 @@ namespace MatterHackers.MatterControl } } + tempImage.SetRecieveBlender(new BlenderPreMultBGRA()); + AllWhite.DoAllWhite(tempImage); + // and give it back return tempImage; } @@ -494,22 +497,9 @@ namespace MatterHackers.MatterControl ImageTgaIO.SaveImageData(imageFileName, bigRender); } - ImageBuffer unScaledImage = new ImageBuffer(bigRender.Width, bigRender.Height, 32, new BlenderBGRA()); - unScaledImage.NewGraphics2D().Render(bigRender, 0, 0); - // If the source image (the one we downloaded) is more than twice as big as our dest image. - while (unScaledImage.Width > Width * 2) - { - // The image sampler we use is a 2x2 filter so we need to scale by a max of 1/2 if we want to get good results. - // So we scale as many times as we need to to get the Image to be the right size. - // If this were going to be a non-uniform scale we could do the x and y separatly to get better results. - ImageBuffer halfImage = new ImageBuffer(unScaledImage.Width / 2, unScaledImage.Height / 2, 32, new BlenderBGRA()); - halfImage.NewGraphics2D().Render(unScaledImage, 0, 0, 0, halfImage.Width / (double)unScaledImage.Width, halfImage.Height / (double)unScaledImage.Height); - unScaledImage = halfImage; - } + bigRender.SetRecieveBlender(new BlenderPreMultBGRA()); - this.thumbnailImage = new ImageBuffer((int)Width, (int)Height, 32, new BlenderBGRA()); - this.thumbnailImage.NewGraphics2D().Clear(new RGBA_Bytes(255, 255, 255, 0)); - this.thumbnailImage.NewGraphics2D().Render(unScaledImage, 0, 0, 0, (double)this.thumbnailImage.Width / unScaledImage.Width, (double)this.thumbnailImage.Height / unScaledImage.Height); + this.thumbnailImage = ImageBuffer.CreateScaledImage(bigRender, (int)Width, (int)Height); UiThread.RunOnIdle(this.EnsureImageUpdated); @@ -689,22 +679,9 @@ namespace MatterHackers.MatterControl return false; } - ImageBuffer unScaledImage = new ImageBuffer(bigRender.Width, bigRender.Height, 32, new BlenderBGRA()); - unScaledImage.NewGraphics2D().Render(bigRender, 0, 0); - // If the source image (the one we downloaded) is more than twice as big as our dest image. - while (unScaledImage.Width > Width * 2) - { - // The image sampler we use is a 2x2 filter so we need to scale by a max of 1/2 if we want to get good results. - // So we scale as many times as we need to to get the Image to be the right size. - // If this were going to be a non-uniform scale we could do the x and y separatly to get better results. - ImageBuffer halfImage = new ImageBuffer(unScaledImage.Width / 2, unScaledImage.Height / 2, 32, new BlenderBGRA()); - halfImage.NewGraphics2D().Render(unScaledImage, 0, 0, 0, halfImage.Width / (double)unScaledImage.Width, halfImage.Height / (double)unScaledImage.Height); - unScaledImage = halfImage; - } + bigRender.SetRecieveBlender(new BlenderPreMultBGRA()); - this.thumbnailImage = new ImageBuffer((int)Width, (int)Height, 32, new BlenderBGRA()); - this.thumbnailImage.NewGraphics2D().Clear(new RGBA_Bytes(255, 255, 255, 0)); - this.thumbnailImage.NewGraphics2D().Render(unScaledImage, 0, 0, 0, (double)this.thumbnailImage.Width / unScaledImage.Width, (double)this.thumbnailImage.Height / unScaledImage.Height); + this.thumbnailImage = ImageBuffer.CreateScaledImage(bigRender, (int)Width, (int)Height); UiThread.RunOnIdle(this.EnsureImageUpdated); @@ -714,4 +691,54 @@ namespace MatterHackers.MatterControl return false; } } + + public class AllWhite + { + public static void DoAllWhite(ImageBuffer sourceImageAndDest) + { + DoAllWhite(sourceImageAndDest, sourceImageAndDest); + } + + public static void DoAllWhite(ImageBuffer result, ImageBuffer imageA) + { + if (imageA.BitDepth != result.BitDepth) + { + throw new NotImplementedException("All the images have to be the same bit depth."); + } + if (imageA.Width != result.Width || imageA.Height != result.Height) + { + throw new Exception("All images must be the same size."); + } + + switch (imageA.BitDepth) + { + case 32: + { + int height = imageA.Height; + int width = imageA.Width; + byte[] resultBuffer = result.GetBuffer(); + byte[] imageABuffer = imageA.GetBuffer(); + for (int y = 0; y < height; y++) + { + int offsetA = imageA.GetBufferOffsetY(y); + int offsetResult = result.GetBufferOffsetY(y); + + for (int x = 0; x < width; x++) + { + int alaph = imageABuffer[3]; + resultBuffer[offsetResult++] = (byte)255; offsetA++; + resultBuffer[offsetResult++] = (byte)255; offsetA++; + resultBuffer[offsetResult++] = (byte)255; offsetA++; + resultBuffer[offsetResult++] = imageABuffer[offsetA++]; + } + } + result.SetRecieveBlender(new BlenderPreMultBGRA()); + } + break; + + default: + throw new NotImplementedException(); + } + } + } } \ No newline at end of file diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs index 4bc53c031..9f7e557e8 100644 --- a/MatterControlApplication.cs +++ b/MatterControlApplication.cs @@ -39,7 +39,6 @@ using MatterHackers.MatterControl.SettingsManagement; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.PolygonMesh.Processors; using MatterHackers.RenderOpenGl.OpenGl; -using MatterHackers.GuiAutomation; using MatterHackers.VectorMath; using Mindscape.Raygun4Net; using System; diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 2f6c1acef..4850acfe1 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 2f6c1acef41b7cab790da4625f2dd1173638e0b6 +Subproject commit 4850acfe15002353aca78e2278e06a48f7b54549