本文整理汇总了C#中MatterHackers.Agg.Image.ImageBuffer类的典型用法代码示例。如果您正苦于以下问题:C# ImageBuffer类的具体用法?C# ImageBuffer怎么用?C# ImageBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageBuffer类属于MatterHackers.Agg.Image命名空间,在下文中一共展示了ImageBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AForgeCamera
public AForgeCamera(string preferedCameraName = null, int preferedWidth = 640, int preferedHeight = 480, DownSample downSampleVideo = DownSample.None)
{
this.downSampleVideo = downSampleVideo;
if (preferedCameraName != null)
{
FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo info in videoDevices)
{
if (info.Name.Contains(preferedCameraName))
{
videoCaptureDevice = new VideoCaptureDevice(info.MonikerString);
videoCaptureDevice.DesiredFrameSize = new Size(preferedWidth, preferedHeight);
break;
}
}
}
if (videoCaptureDevice == null)
{
VideoCaptureDeviceForm form = new VideoCaptureDeviceForm();
if (form.ShowDialog(null) == DialogResult.OK)
{
// create video source
videoCaptureDevice = form.VideoDevice;
}
}
if (videoCaptureDevice != null)
{
//videoCaptureDevice.DesiredFrameRate = 5;
//videoCaptureDevice.ProvideSnapshots = true;
//videoCaptureDevice.DesiredSnapshotSize = new Size(preferedWidth, preferedHeight);
//videoCaptureDevice.SnapshotFrame += new NewFrameEventHandler(videoCaptureDevice_SnapshotFrame);
asyncCopiedVideoImage = new ImageBuffer(videoCaptureDevice.DesiredFrameSize.Width, videoCaptureDevice.DesiredFrameSize.Height, 32, new BlenderBGRA());
if (downSampleVideo == DownSample.HalfSize)
{
imageForExternalUse = new ImageBuffer(videoCaptureDevice.DesiredFrameSize.Width / 2, videoCaptureDevice.DesiredFrameSize.Height / 2, 32, new BlenderBGRA());
}
else
{
imageForExternalUse = new ImageBuffer(videoCaptureDevice.DesiredFrameSize.Width, videoCaptureDevice.DesiredFrameSize.Height, 32, new BlenderBGRA());
}
videoCaptureDevice.Start();
videoCaptureDevice.NewFrame += new NewFrameEventHandler(source_NewFrame);
}
}
示例2: LibraryThumbnailWidget
public LibraryThumbnailWidget(PrintItemWrapper item, string noThumbnailFileName, string buildingThumbnailFileName, Vector2 size)
{
this.PrintItem = item;
// Set Display Attributes
this.Margin = new BorderDouble(0);
this.Padding = new BorderDouble(5);
this.Width = size.x;
this.Height = size.y;
this.MinimumSize = size;
this.BackgroundColor = normalBackgroundColor;
this.Cursor = Cursors.Hand;
// set background images
if (noThumbnailImage.Width == 0)
{
ImageBMPIO.LoadImageData(this.GetImageLocation(noThumbnailFileName), noThumbnailImage);
ImageBMPIO.LoadImageData(this.GetImageLocation(buildingThumbnailFileName), buildingThumbnailImage);
}
this.image = new ImageBuffer(buildingThumbnailImage);
// Add Handlers
this.Click += new ButtonEventHandler(onMouseClick);
this.MouseEnterBounds += new EventHandler(onEnter);
this.MouseLeaveBounds += new EventHandler(onExit);
ActiveTheme.Instance.ThemeChanged.RegisterEvent(onThemeChanged, ref unregisterEvents);
CreateThumNailThreadIfNeeded();
}
示例3: CreateOptionsMenu
GuiWidget CreateOptionsMenu()
{
ImageBuffer gearImage = new ImageBuffer();
string imagePathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "gear_icon.png");
ImageBMPIO.LoadImageData(imagePathAndFile, gearImage);
FlowLayoutWidget leftToRight = new FlowLayoutWidget();
leftToRight.Margin = new BorderDouble(5, 0);
string optionsString = new LocalizedString("Options").Translated;
TextWidget optionsText = new TextWidget(optionsString, textColor: RGBA_Bytes.White);
optionsText.VAnchor = Agg.UI.VAnchor.ParentCenter;
optionsText.Margin = new BorderDouble(0, 0, 3, 0);
leftToRight.AddChild(optionsText);
GuiWidget gearWidget = new ImageWidget(gearImage);
gearWidget.VAnchor = Agg.UI.VAnchor.ParentCenter;
leftToRight.AddChild(gearWidget);
leftToRight.HAnchor = HAnchor.FitToChildren;
leftToRight.VAnchor = VAnchor.FitToChildren;
Menu optionMenu = new Menu(leftToRight);
optionMenu.OpenOffset = new Vector2(-2, -10);
optionMenu.VAnchor = Agg.UI.VAnchor.ParentCenter;
optionMenu.MenuItems.Add(new MenuItem(new ThemeColorSelectorWidget()));
return optionMenu;
}
示例4: OutputImage
private void OutputImage(ImageBuffer imageToOutput, string fileName)
{
if (saveImagesForDebug)
{
ImageTgaIO.Save(imageToOutput, fileName);
}
}
示例5: ContainsTests
public void ContainsTests()
{
// look for 24 bit
{
ImageBuffer imageToSearch = new ImageBuffer(150, 150, 24, new BlenderBGR());
imageToSearch.NewGraphics2D().Circle(new Vector2(100, 100), 3, RGBA_Bytes.Red);
ImageBuffer circleToFind = new ImageBuffer(10, 10, 24, new BlenderBGR());
circleToFind.NewGraphics2D().Circle(new Vector2(5, 5), 3, RGBA_Bytes.Red);
Assert.IsTrue(imageToSearch.Contains(circleToFind), "We should be able to find the circle.");
ImageBuffer squareToFind = new ImageBuffer(10, 10, 24, new BlenderBGR());
squareToFind.NewGraphics2D().FillRectangle(4, 4, 8, 8, RGBA_Bytes.Red);
Assert.IsTrue(!imageToSearch.Contains(squareToFind), "We should be not find a square.");
}
// look for 32 bit
{
ImageBuffer imageToSearch = new ImageBuffer(150, 150, 32, new BlenderBGRA());
imageToSearch.NewGraphics2D().Circle(new Vector2(100, 100), 3, RGBA_Bytes.Red);
ImageBuffer circleToFind = new ImageBuffer(10, 10, 32, new BlenderBGRA());
circleToFind.NewGraphics2D().Circle(new Vector2(5, 5), 3, RGBA_Bytes.Red);
Assert.IsTrue(imageToSearch.Contains(circleToFind), "We should be able to find the circle.");
ImageBuffer squareToFind = new ImageBuffer(10, 10, 32, new BlenderBGRA());
squareToFind.NewGraphics2D().FillRectangle(4, 4, 8, 8, RGBA_Bytes.Red);
Assert.IsTrue(!imageToSearch.Contains(squareToFind), "We should be not find a square.");
}
}
示例6: DoubleBufferTests
public void DoubleBufferTests()
{
{
bool textWidgetDoubleBufferDefault = TextWidget.DoubleBufferDefault;
// the text widget is double buffered
TextWidget.DoubleBufferDefault = true;
ImageBuffer doubleBufferImage = new ImageBuffer(65, 50, 24, new BlenderBGR());
Button doubleBufferButton = new Button("testing", 0, 0);
doubleBufferButton.OnDraw(doubleBufferImage.NewGraphics2D());
SaveImage(doubleBufferImage, "z control.tga");
// make sure the frame comparison function works.
{
ImageBuffer doubleBufferImageCopy = new ImageBuffer(doubleBufferImage, new BlenderBGR());
Assert.IsTrue(doubleBufferImage == doubleBufferImageCopy);
}
// the text widget is not double buffered
TextWidget.DoubleBufferDefault = false;
ImageBuffer notDoubleBufferImage = new ImageBuffer(65, 50, 24, new BlenderBGR());
Button notDoubleBufferButton = new Button("testing", 0, 0);
notDoubleBufferButton.OnDraw(notDoubleBufferImage.NewGraphics2D());
SaveImage(notDoubleBufferImage, "z test.tga");
Assert.IsTrue(doubleBufferImage == notDoubleBufferImage);
TextWidget.DoubleBufferDefault = textWidgetDoubleBufferDefault;
}
}
示例7: SaveImage
private void SaveImage(ImageBuffer image, string dest)
{
if (saveImagesForDebug)
{
ImageTgaIO.Save(image, dest);
}
}
示例8: DoYBlur
public static void DoYBlur(ImageBuffer sourceDest)
{
if (sourceDest.BitDepth != 8)
{
throw new NotImplementedException("We only work with 8 bit at the moment.");
}
int height = sourceDest.Height;
int width = sourceDest.Width;
byte[] buffer = sourceDest.GetBuffer();
int strideInBytes = sourceDest.StrideInBytes();
byte[] cache = new byte[height];
for (int x = 0; x < width; x++)
{
int offset = x;
for (int y = 0; y < height; y++)
{
cache[y] = buffer[offset];
offset += strideInBytes;
}
offset = x;
for (int y = 1; y < height - 1; y++)
{
int newValue = (cache[y - 1] + cache[y] * 2 + cache[y + 1] + 2) / 4; // the + 2 is so that we will round correctly
buffer[offset] = (byte)newValue;
offset += strideInBytes;
}
}
}
示例9: DoXBlur
internal static void DoXBlur(ImageBuffer sourceDest)
{
if (sourceDest.BitDepth != 8)
{
throw new NotImplementedException("We only work with 8 bit at the moment.");
}
int height = sourceDest.Height;
int width = sourceDest.Width;
byte[] buffer = sourceDest.GetBuffer();
byte[] cache = new byte[width];
for (int y = 0; y < height; y++)
{
int offset = sourceDest.GetBufferOffsetY(y);
for (int x = 0; x < width; x++)
{
cache[x] = buffer[offset + x];
}
for (int x = 1; x < width - 1; x++)
{
int newValue = (cache[x - 1] + cache[x] * 2 + cache[x + 1] + 2) / 4; // the + 2 is so that we will round correctly
buffer[offset + x] = (byte)newValue;
}
}
}
示例10: LoadImage
ImageBuffer LoadImage(string imageName)
{
string path = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, imageName);
ImageBuffer buffer = new ImageBuffer(10, 10, 32, new BlenderBGRA());
ImageBMPIO.LoadImageData(path, buffer);
return buffer;
}
示例11: TextureMaterial
public TextureMaterial(ImageBuffer texture, double reflection, double transparency, double gloss, double density)
{
this.Reflection = reflection;
this.Transparency = transparency;
this.Gloss = gloss;
this.Density = density;
this.Texture = texture;
}
示例12: CreateWhiteToColor
public static ImageBuffer CreateWhiteToColor(ImageBuffer normalImage, RGBA_Bytes color)
{
ImageBuffer destImage = new ImageBuffer(normalImage.Width, normalImage.Height, 32, new BlenderBGRA());
DoWhiteToColor(destImage, normalImage, color);
return destImage;
}
示例13: OnDraw
public override void OnDraw(Graphics2D graphics2D)
{
ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());
IImageByte backBuffer = widgetsSubImage;
GammaLookUpTable gamma = new GammaLookUpTable(m_gamma.Value);
IRecieveBlenderByte NormalBlender = new BlenderBGRA();
IRecieveBlenderByte GammaBlender = new BlenderGammaBGRA(gamma);
ImageBuffer rasterNormal = new ImageBuffer();
rasterNormal.Attach(backBuffer, NormalBlender);
ImageBuffer rasterGamma = new ImageBuffer();
rasterGamma.Attach(backBuffer, GammaBlender);
ImageClippingProxy clippingProxyNormal = new ImageClippingProxy(rasterNormal);
ImageClippingProxy clippingProxyGamma = new ImageClippingProxy(rasterGamma);
clippingProxyNormal.clear(m_white_on_black.Checked ? new RGBA_Floats(0, 0, 0) : new RGBA_Floats(1, 1, 1));
ScanlineRasterizer ras = new ScanlineRasterizer();
ScanlineCachePacked8 sl = new ScanlineCachePacked8();
VertexSource.Ellipse e = new VertexSource.Ellipse();
// TODO: If you drag the control circles below the bottom of the window we get an exception. This does not happen in AGG.
// It needs to be debugged. Turning on clipping fixes it. But standard agg works without clipping. Could be a bigger problem than this.
//ras.clip_box(0, 0, width(), height());
// Render two "control" circles
e.init(m_x[0], m_y[0], 3, 3, 16);
ras.add_path(e);
ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
scanlineRenderer.render_scanlines_aa_solid(clippingProxyNormal, ras, sl, new RGBA_Bytes(127, 127, 127));
e.init(m_x[1], m_y[1], 3, 3, 16);
ras.add_path(e);
scanlineRenderer.render_scanlines_aa_solid(clippingProxyNormal, ras, sl, new RGBA_Bytes(127, 127, 127));
double d = m_offset.Value;
// Creating a rounded rectangle
VertexSource.RoundedRect r = new VertexSource.RoundedRect(m_x[0] + d, m_y[0] + d, m_x[1] + d, m_y[1] + d, m_radius.Value);
r.normalize_radius();
// Drawing as an outline
if (!m_DrawAsOutlineCheckBox.Checked)
{
Stroke p = new Stroke(r);
p.width(1.0);
ras.add_path(p);
}
else
{
ras.add_path(r);
}
scanlineRenderer.render_scanlines_aa_solid(clippingProxyGamma, ras, sl, m_white_on_black.Checked ? new RGBA_Bytes(255, 255, 255) : new RGBA_Bytes(0, 0, 0));
base.OnDraw(graphics2D);
}
示例14: LoadImage
private ImageBuffer LoadImage(string imageName)
{
string path = Path.Combine("Icons", imageName);
ImageBuffer buffer = new ImageBuffer(10, 10, 32, new BlenderBGRA());
StaticData.Instance.LoadImage(path, buffer);
return buffer;
}
示例15: InternalImageGraphics2D
internal InternalImageGraphics2D(ImageBuffer owner)
: base()
{
ScanlineRasterizer rasterizer = new ScanlineRasterizer();
ImageClippingProxy imageClippingProxy = new ImageClippingProxy(owner);
Initialize(imageClippingProxy, rasterizer);
ScanlineCache = new ScanlineCachePacked8();
}