Made a new high quality render mode for image buffer graphics 2d.
Turned off the automation test. Made the thumbnails look better.
This commit is contained in:
parent
c1f0dd8b1f
commit
9b79422532
4 changed files with 58 additions and 68 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 2f6c1acef41b7cab790da4625f2dd1173638e0b6
|
||||
Subproject commit 4850acfe15002353aca78e2278e06a48f7b54549
|
||||
Loading…
Add table
Add a link
Reference in a new issue