本文整理汇总了C#中MatterHackers.Agg.Image.ImageBuffer.GetBounds方法的典型用法代码示例。如果您正苦于以下问题:C# ImageBuffer.GetBounds方法的具体用法?C# ImageBuffer.GetBounds怎么用?C# ImageBuffer.GetBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatterHackers.Agg.Image.ImageBuffer
的用法示例。
在下文中一共展示了ImageBuffer.GetBounds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FloodFillDemo
public FloodFillDemo()
{
BackgroundColor = RGBA_Bytes.White;
imageToFillOn = new ImageBuffer(400, 300, 32, new BlenderBGRA());
Graphics2D imageToFillGraphics = imageToFillOn.NewGraphics2D();
imageToFillGraphics.Clear(RGBA_Bytes.White);
imageToFillGraphics.DrawString("Click to fill", 20, 30);
imageToFillGraphics.Circle(new Vector2(200, 150), 35, RGBA_Bytes.Black);
imageToFillGraphics.Circle(new Vector2(200, 150), 30, RGBA_Bytes.Green);
imageToFillGraphics.Rectangle(20, 50, 210, 280, RGBA_Bytes.Black);
imageToFillGraphics.Rectangle(imageToFillOn.GetBounds(), RGBA_Bytes.Blue);
Random rand = new Random();
for (int i = 0; i < 20; i++)
{
Ellipse elipse = new Ellipse(rand.Next(imageToFillOn.Width), rand.Next(imageToFillOn.Height), rand.Next(10, 60), rand.Next(10, 60));
Stroke outline = new Stroke(elipse);
imageToFillGraphics.Render(outline, RGBA_Bytes.Black);
}
m_slider1 = new Slider(new Vector2(80, 10), 510);
m_slider2 = new Slider(new Vector2(80, 10 + 20), 510);
m_slider1.ValueChanged += new EventHandler(NeedsRedraw);
m_slider2.ValueChanged += new EventHandler(NeedsRedraw);
AddChild(m_slider1);
AddChild(m_slider2);
m_slider1.Text = "Pixel size={0:F3}";
m_slider1.SetRange(8, 100);
m_slider1.NumTicks = 23;
m_slider1.Value = 32;
m_slider2.Text = "gamma={0:F3}";
m_slider2.SetRange(0.0, 3.0);
m_slider2.Value = 1.0;
}
示例2: DEBUG_saveImageBuffer
private void DEBUG_saveImageBuffer(ImageBuffer buf)
{
int hash = 0;
var bounds = buf.GetBounds ();
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap (bounds.Width, bounds.Height, PixelFormat.Format32bppArgb);
for (int x = 0; x < bounds.Width; x++) {
for (int y = 0; y < bounds.Height; y++) {
var pcolor = buf.GetPixel (x, y);
var wcolor = Color.FromArgb (pcolor.alpha, pcolor.red, pcolor.green, pcolor.green);
hash += wcolor.ToArgb () ^ 0x1f2f019f;
hash <<= 1;
bitmap.SetPixel (x, y, wcolor);
}
}
string filename = String.Format (@"C:\tmp\masktest-{0}.bmp", hash);
if (!System.IO.File.Exists (filename)) {
bitmap.Save (filename, ImageFormat.Bmp);
}
}