本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
}
示例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 );
}
}
示例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);
}
示例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();
}
}