当前位置: 首页>>代码示例>>C#>>正文


C# Bitmap.Clear方法代码示例

本文整理汇总了C#中Microsoft.SPOT.Bitmap.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# Bitmap.Clear方法的具体用法?C# Bitmap.Clear怎么用?C# Bitmap.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.SPOT.Bitmap的用法示例。


在下文中一共展示了Bitmap.Clear方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    const string text = "Hello World";
                    int textWidth, textHeight;

                    Font font = Resources.GetFont(Resources.FontResources.ninabd18ppem);
                    font.ComputeExtent(text, out textWidth, out textHeight);
                    int textX = (Dimensions.Width - textWidth)/2;

                    var rand = new Random();

                    for (int x = 0; x < 3; x++)
                    {
                        int baseColor = rand.Next(0xffff);
                        for (int i = 0; i < Dimensions.Height; i++)
                        {
                            bmp.Clear();
                            bmp.DrawText(text, font, (Color) (((255 - i) << 16) | baseColor), textX, i);
                            bmp.Flush();
                        }
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
开发者ID:dario-l,项目名称:kodfilemon.blogspot.com,代码行数:33,代码来源:DrawTextTest.cs

示例2: Run

        public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    //var resId = Resources.BitmapResources.smile;
                    var resId = Resources.BitmapResources.spotlogo110;
                    using (Bitmap src = Resources.GetBitmap(resId))
                    {
                        if(resId == Resources.BitmapResources.smile)
                            src.MakeTransparent(src.GetPixel(0,0));

                        var rand = new Random();

                        int xPos = rand.Next(Dimensions.Width - src.Width);
                        int yPos = rand.Next(Dimensions.Height - src.Height);

                        int xDir = 3;
                        int yDir = 4;

                        for (int animcount = 0; animcount < 100; animcount++)
                        {
                            bmp.Clear();
                            bmp.DrawImage(xPos, yPos, src, 0, 0, src.Width, src.Height);
                            bmp.Flush();

                            xPos = xPos + xDir;
                            yPos = yPos + yDir;

                            if (xPos + src.Width > bmp.Width || xPos < 0)
                            {
                                xDir = -xDir;
                                xPos += xDir;
                            }
                            if (yPos + src.Height > bmp.Height || yPos < 0)
                            {
                                yDir = -yDir;
                                yPos += yDir;
                            }

                            Thread.Sleep(10);
                        }
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
开发者ID:dario-l,项目名称:kodfilemon.blogspot.com,代码行数:52,代码来源:Bouncy.cs

示例3: Main

        public static void Main()
        {
            // initialize display buffer
            _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);

            // sample "hello world" code
            _display.Clear();
            Font fontNinaB = Resources.GetFont(Resources.FontResources.NinaB);
            _display.DrawText("Waiting.", fontNinaB, Color.White, 10, 64);
            _display.Flush();

            var connection = new Connection("COM3", new CSVChannel());
            connection.Open();
            connection.OnReceived+=connection_OnReceived;
            // go to sleep; all further code should be timer-driven or event-driven
            Thread.Sleep(Timeout.Infinite);
        }
开发者ID:nothingmn,项目名称:zVirtualScenes-Client,代码行数:17,代码来源:Program.cs

示例4: Run

        public override void Run()
        {
            Font font = Resources.GetFont(Resources.FontResources.ninabd18ppem);
            using (var bitmap = new Bitmap(Dimensions.Width, Dimensions.Height))
            {
                for (int i = 0; i < 4; i++)
                {
                    bitmap.Clear();
                    bitmap.Flush();
                    Thread.Sleep(1000);

                    bitmap.DrawTextInRect("kodFilemon\n.blogspot\n.com", 0, 10,
                                          Dimensions.Width, Dimensions.Height-10,
                                          Bitmap.DT_AlignmentCenter, Colors.White, font);
                    bitmap.Flush();
                    Thread.Sleep(1000);
                }
            }
        }
开发者ID:dario-l,项目名称:kodfilemon.blogspot.com,代码行数:19,代码来源:KodFilemon.cs

示例5: Run

        public override void Run()
        {
            try
            {
                using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
                {
                    var fonts = new[]
                                    {
                                        new FontItem {Name = "Arial 10", FontId = Resources.FontResources.arial10},
                                        new FontItem {Name = "Small", FontId = Resources.FontResources.small},
                                        new FontItem {Name = "Courier 11", FontId = Resources.FontResources.courier11}
                                    };

                    const string s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";

                    foreach (var font in fonts)
                    {
                        bmp.Clear();

                        Font fnt = Resources.GetFont(font.FontId);

                        bmp.DrawRectangle((Color)0xFF0000, 0, 0, 0,
                                          Dimensions.Width, Dimensions.Height,
                                          0, 0, (Color)0xFF0000, 0, 0, (Color)0xFF0000, 0, 0,
                                          Bitmap.OpacityOpaque);

                        const Color color = (Color)0x0000FF;
                        bmp.DrawTextInRect(font.Name + " " + s, 0, 0, Dimensions.Width, Dimensions.Height,
                                           Bitmap.DT_WordWrap | Bitmap.DT_AlignmentLeft, color, fnt);

                        bmp.Flush();

                        Thread.Sleep(5000);
                    }
                }
                Pass = true;
            }
            catch (Exception e)
            {
                UnexpectedException(e);
            }
        }
开发者ID:dario-l,项目名称:kodfilemon.blogspot.com,代码行数:42,代码来源:DrawText.cs

示例6: Run

        public override void Run()
        {
            using (var bitmap = new Bitmap(Dimensions.Width, Dimensions.Height))
            {
                try
                {
                    bitmap.Clear();

                    using (Bitmap bmp = Resources.GetBitmap(Resources.BitmapResources.Jpeg01Normal))
                        bitmap.DrawImage(0, 0, bmp, 0, 0, bmp.Width, bmp.Height);

                    bitmap.Flush();
                    Thread.Sleep(3000);
                    Pass = true;
                }
                catch (Exception e)
                {
                    UnexpectedException(e);
                }
            }
        }
开发者ID:dario-l,项目名称:kodfilemon.blogspot.com,代码行数:21,代码来源:JpegArray.cs

示例7: Main

        /// <summary>
        /// A demonstration as to how to handle multiple button presses at the same time
        /// </summary>

        public static void Main()
        {

            ButtonHelper.ButtonSetup = new Buttons[]{ Buttons.TopRight, Buttons.MiddleRight, Buttons.BottomRight,};
            ButtonHelper.Current.OnButtonPress += Current_OnButtonPress;

            buttonStates = new Hashtable();
            buttonStates.Add(Buttons.TopRight, ButtonDirection.Up);
            buttonStates.Add(Buttons.MiddleRight, ButtonDirection.Up);
            buttonStates.Add(Buttons.BottomRight, ButtonDirection.Up);

            // initialize display buffer
            _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);

            // sample "hello world" code
            _display.Clear();
            _display.DrawText("Hello world.", fontNinaB, Color.White, 10, 64);
            _display.Flush();

            // go to sleep; all further code should be timer-driven or event-driven
            Thread.Sleep(Timeout.Infinite);
        }
开发者ID:nicksi,项目名称:AGENT.Contrib,代码行数:26,代码来源:Program.cs

示例8: Run

        public override void Run()
        {
            int focus = 15;
            
            using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
            {
                DateTime barier = DateTime.Now.AddSeconds(5);
                while(DateTime.Now < barier)
                {
                    bmp.Clear();

                    foreach (var star in _stars)
                    {
                        int x = star.X*focus/star.Z + Dimensions.Width/2;
                        int y = Dimensions.Height/2 - star.Y*focus/star.Z;

                        if (x >= 0 && y >= 0 && x <= bmp.Width && y <= bmp.Height)
                        {
                            if (star.Z > 20)
                                bmp.SetPixel(x, y, Color.White);
                            else
                            {
                                bmp.SetPixel(x, y, Color.White);
                                bmp.SetPixel(x - 1, y, Color.White);
                                bmp.SetPixel(x + 1, y, Color.White);
                                bmp.SetPixel(x, y - 1, Color.White);
                                bmp.SetPixel(x, y + 1, Color.White);
                            }
                        }

                        star.Fly();
                    }

                    bmp.Flush();
                    Thread.Sleep(5);
                }
            }
        }
开发者ID:dario-l,项目名称:kodfilemon.blogspot.com,代码行数:38,代码来源:MilkyWay.cs

示例9: Run

        public override void Run()
        {
            Bitmap bitmap = new Bitmap( Dimensions.Width, Dimensions.Height );
                
            try
            {
                bitmap.Clear();

                byte[] byteArr = Resources.GetBytes( Resources.BinaryResources.JpegNormal );
                Bitmap bmp = new Bitmap( byteArr, Bitmap.BitmapImageType.Jpeg );

                bitmap.DrawImage( 0, 0, bmp, 0, 0, bmp.Width, bmp.Height );

                bitmap.Flush();
                Thread.Sleep(2000);
                Pass = true;
            }
            catch(Exception e)
            {
                UnexpectedException( e );
            }
            
        }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:23,代码来源:Main.cs

示例10: Main

        public static void Main()
        {
            ButtonHelper.ButtonSetup = new Buttons[]{Buttons.BottomRight, Buttons.MiddleRight, Buttons.TopRight,  };
            ButtonHelper.Current.OnButtonPress += Current_OnButtonPress;
            // initialize display buffer
            _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);

            // sample "hello world" code
            _display.Clear();
            var drawing = new Agent.Contrib.Drawing.Drawing();
            drawing.DrawAlignedText(_display, Color.White, font, "Connect...", HAlign.Center, 0, VAlign.Middle, 0);
            _display.Flush();
            

            p = new SerialPort("COM1");
            p.DataReceived += p_DataReceived;
            p.Open();




            // go to sleep; all further code should be timer-driven or event-driven
            Thread.Sleep(Timeout.Infinite);
        }
开发者ID:nothingmn,项目名称:WP8-Running.AGENT,代码行数:24,代码来源:Program.cs

示例11: Render

        public void Render(Bitmap screen)
        {
            Screen = screen;
            if (Buttons != null)
            {
                screen.Clear();
                foreach (CalculatorButton button in Buttons)
                {
                    button.Render(screen, font, ButtonHeight, ButtonWidth, ButtonBorder, ForegroundColor,
                                  BackgroundColor);
                }


                //calculation result
                screen.DrawText(input, font, BackgroundColor, 2, 2);
                screen.DrawText(secondInput + op, font, BackgroundColor, 2, 2 + font.Height + 2);

                //draw a simple border for the digit display
                screen.DrawRectangle(ForegroundColor, 1, 1, 1, Program.AgentSize, 28, 0, 0,
                                     BackgroundColor, 0, 0, BackgroundColor, 0, 0, 0);

                //draw a simple border
                screen.DrawRectangle(Color.White, 1, 1, 1, Program.AgentSize, Program.AgentSize, 0, 0,
                                     BackgroundColor, 0, 0, BackgroundColor, 0, 0, 0);

                screen.Flush();
            }
        }
开发者ID:nothingmn,项目名称:Agent.SimpleCalculator,代码行数:28,代码来源:Calculator.cs


注:本文中的Microsoft.SPOT.Bitmap.Clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。