コード例 #1
0
ファイル: FloodFill.cs プロジェクト: jeske/agg-sharp
        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
0
ファイル: GDIviaAGG.cs プロジェクト: RealRui/SimpleScene
        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);
            }
        }