本文整理汇总了C#中Microsoft.SPOT.Bitmap.DrawImage方法的典型用法代码示例。如果您正苦于以下问题:C# Bitmap.DrawImage方法的具体用法?C# Bitmap.DrawImage怎么用?C# Bitmap.DrawImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.SPOT.Bitmap
的用法示例。
在下文中一共展示了Bitmap.DrawImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
//private Bitmap img = new Bitmap(Resources.GetBytes(Resources.BinaryResources.AnalogTicksOutside),
// Bitmap.BitmapImageType.Gif);
//private Bitmap img = new Bitmap(Resources.GetBytes(Resources.BinaryResources.AnalogTicksInside),
// Bitmap.BitmapImageType.Gif);
public override void Render(Bitmap screen)
{
if (_screen == null) _screen = screen;
screen.DrawImage(0, 0, img, 0, 0, img.Width, img.Height);
var text = "AGENT";
Point textLocation = new Point(
AGENT.Center.X - (drawing.MeasureString(text, smallFont) / 2), AGENT.Center.Y - 25);
screen.DrawText(text, smallFont, Color.White, textLocation.X, textLocation.Y);
var date = Settings.Now.ToString(CultureInfo.CurrentUICulture.DateTimeFormat.MonthDayPattern);
; //time.MonthNameShort + " " + time.Day;
Point dateLocation = new Point(
AGENT.Center.X - (drawing.MeasureString(date, smallFont) / 2), AGENT.Center.Y + 20);
screen.DrawText(date, smallFont, Color.White, dateLocation.X, dateLocation.Y);
//draw our hands
drawing.PaintSkinnyHands(screen, Settings.Now, AGENT.Center);
drawing.DrawTray(screen, _notificationProvider, smallFont);
}
示例2: Main
public static void Main()
{
int screenWidth, screenHeight, bitsPerPixel, orientationDeg;
HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, out screenHeight,
out bitsPerPixel, out orientationDeg);
//prepare background with a color gradient
Bitmap backgroundImg = new Bitmap(screenWidth, screenHeight);
backgroundImg.DrawRectangle(Color.White, // outline color
0, // outline thickness
0, 0, // x and y of top left corner
backgroundImg.Width, // width
backgroundImg.Height, // height
0, 0, // x and y corner radius
Color.White, // gradient start color
0, 0, // gradient start coordinates
Color.Black, // gradient end color
backgroundImg.Width, // gradient end x coordinate
backgroundImg.Height, // gradient end y coordinate
Bitmap.OpacityOpaque); // opacity
//prepare a working buffer to hold graphics before flushing to display
Bitmap bufferImg = new Bitmap(screenWidth, screenHeight);
//our ball
Bitmap soccerBallImg = Resources.GetBitmap(Resources.BitmapResources.SoccerBall);
//make background of the ball transparent
//using the color of top left corner pixel
soccerBallImg.MakeTransparent(soccerBallImg.GetPixel(0, 0));
int x = 100;
int y = 50;
int xOfs = 1;
int yOfs = 1;
while (true)
{
//copy background to buffer
bufferImg.DrawImage(0, 0, backgroundImg, 0, 0,
backgroundImg.Width, backgroundImg.Height);
//paint moving sprite object
bufferImg.DrawImage(x, y, // destination coordinates
soccerBallImg, // source image
0, 0, // source coordinates
soccerBallImg.Width, soccerBallImg.Height,
Bitmap.OpacityOpaque);
bufferImg.Flush(); //flush buffer to display
Thread.Sleep(10);
//invert direction if ball bounces at a wall
if (x <= 0 || x >= screenWidth - soccerBallImg.Width)
xOfs = -xOfs;
if (y <= 0 || y >= screenHeight - soccerBallImg.Height)
yOfs = -yOfs;
//calculate new coordinates
x += xOfs;
y += yOfs;
}
}
示例3: RenderRectangle
protected internal override void RenderRectangle(Bitmap bmp, Pen pen, int x, int y, int width, int height, int xCornerRadius, int yCornerRadius)
{
if (Stretch == Stretch.None)
bmp.DrawImage(x, y, BitmapSource, 0, 0, BitmapSource.Width, BitmapSource.Height, Opacity);
else if (width == BitmapSource.Width && height == BitmapSource.Height)
bmp.DrawImage(x, y, BitmapSource, 0, 0, width, height, Opacity);
else
bmp.StretchImage(x, y, BitmapSource, width, height, Opacity);
if (pen != null && pen.Thickness > 0)
bmp.DrawRectangle((MSMedia.Color)pen.Color, pen.Thickness, x, y, width, height, xCornerRadius, yCornerRadius, (MSMedia.Color)0, 0, 0, (MSMedia.Color)0, 0, 0, 0);
}
示例4: Run
public override void Run()
{
try
{
using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
{
var bitmaps = new[]
{
Resources.BitmapResources.cat2,
Resources.BitmapResources.cat1,
Resources.BitmapResources.cat3
};
for (int i = 0; i < bitmaps.Length; i++)
{
using (Bitmap src = Resources.GetBitmap(bitmaps[i]))
bmp.DrawImage(0, 0, src, 0, 0, src.Width, src.Height);
bmp.Flush();
Thread.Sleep(2000);
}
}
Pass = true;
}
catch (Exception e)
{
UnexpectedException(e);
}
}
示例5: DisplayFile
public void DisplayFile(string fileName)
{
var bitmap = new Bitmap(320, 240);
var image = _sdCardDevice.LoadBitmap(fileName, Bitmap.BitmapImageType.Jpeg);
bitmap.DrawImage((320 - image.Width) / 2, (240 - image.Height) / 2, image, 0, 0, image.Width, image.Height);
bitmap.Flush();
}
示例6: Run
public override void Run()
{
try
{
using (var bmp = new Bitmap(20, 20))
bmp.DrawImage(0, 0, bmp, 0, 0, bmp.Width, bmp.Height);
}
catch
{
Pass = true;
}
}
示例7: 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);
}
}
示例8: Main
public static void Main()
{
int screenWidth, screenHeight, bitsPerPixel, orientationDeg;
HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, out screenHeight,
out bitsPerPixel, out orientationDeg);
Bitmap bmp = new Bitmap(screenWidth, screenHeight);
Bitmap soccerBall = Resources.GetBitmap(Resources.BitmapResources.SoccerBall);
bmp.DrawImage(100, 50, // destination coordinates
soccerBall, // source image
0, 0, // source coordinates
soccerBall.Width, // source width
soccerBall.Height, // source height
Bitmap.OpacityOpaque); // opacity
bmp.Flush();
Thread.Sleep(-1); //do not terminate app to see result
}
示例9: Main
public static void Main()
{
int screenWidth, screenHeight, bitsPerPixel, orientationDeg;
HardwareProvider.HwProvider.GetLCDMetrics(out screenWidth, out screenHeight,
out bitsPerPixel, out orientationDeg);
Bitmap bmp = new Bitmap(screenWidth, screenHeight);
Bitmap soccerBall = Resources.GetBitmap(Resources.BitmapResources.SoccerBall);
//make background of the ball transparent
//using the color of top left corner pixel
soccerBall.MakeTransparent(soccerBall.GetPixel(0, 0));
bmp.DrawImage(100, 50, // destination coordinates
soccerBall, // source image
0, 0, // source coordinates
soccerBall.Width, // source width
soccerBall.Height, // source height
Bitmap.OpacityOpaque); // opacity
bmp.Flush();
Thread.Sleep(-1); //do not terminate app to see result
}
示例10: Render
public void Render(Bitmap screen, bool military, ArrayList forecast)
{
var time = new Time();
time.CurrentTime = DateTime.Now;
screen.DrawImage(0, 0, img, 0, 0, img.Width, img.Height);
var text = "agent";
Point textLocation = new Point(
Program.Center.X - (Program.MeasureString(text, font) / 2), Program.Center.Y - 25);
screen.DrawText(text, font, Color.White, textLocation.X, textLocation.Y);
var date = time.MonthNameShort + " " + time.Day;
Point dateLocation = new Point(
Program.Center.X - (Program.MeasureString(date, font) / 2), Program.Center.Y + 20);
screen.DrawText(date, font, Color.White, dateLocation.X, dateLocation.Y);
PaintSkinnyHands(screen, time);
}
示例11: 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);
}
}
}
示例12: Run
public override void Run()
{
try
{
using (var scratch = new Bitmap(64, 32))
{
for (int x = 0; x < scratch.Width; x++)
{
for (int y = 0; y < scratch.Height; y++)
{
Color color = ColorUtility.ColorFromRGB((byte) (x*255/scratch.Width),
(byte) (y*255/(scratch.Height)),
(byte) (255 - x*255/scratch.Width));
scratch.SetPixel(x, y, color);
}
}
using (var bmp = new Bitmap(Dimensions.Width, Dimensions.Height))
{
var rand = new Random();
for (int i = 0; i < 100; i++)
{
bmp.DrawImage(rand.Next(Dimensions.Width),
rand.Next(Dimensions.Height),
scratch, 0, 0,
scratch.Width, scratch.Height);
bmp.Flush();
}
}
}
Pass = true;
}
catch (Exception e)
{
UnexpectedException(e);
}
}
示例13: 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 );
}
}
示例14: Main
public static void Main()
{
string key = "jk4c6nbf6huccmwp";
string label = ".NETmf TOTP";
Bitmap screen = new Bitmap(320, 240); // emulator display size
Font font = Resources.GetFont(Resources.FontResources.NinaB);
otp = new OTP(key);
Bitmap qrcode = otp.QRCode(key, label);
screen.DrawImage(10, 10, qrcode, 0, 0, qrcode.Width, qrcode.Height);
// by design (at least ms and google authenticator) change every 30 seconds(@ 0 and 30)
while (DateTime.Now.Second != 0 && DateTime.Now.Second != 30) ;
while (true)
{
screen.DrawRectangle(Color.Black, 1, 220, 10, 100, 32, 0, 0, Color.Black, 0, 0, Color.Black, 50, 30, 0xff);
screen.DrawText(otp.TOTP, font, Color.White, 220, 10);
screen.Flush();
Thread.Sleep(30000);
}
}
示例15: DrawTray
public void DrawTray(Bitmap screen, IProvideNotifications notificationProvider, Font font )
{
//battery level
var level = Battery.Level;// Util.Random.Next(0, 100);
this.DrawBattery(screen, new Point(1, 0), 13, 9, 1, Color.White, Color.Black, Battery.Charging,
level);
screen.DrawText(level.ToString(), font, Color.White, 15, -2);
var notificationSummary = new NotificationSummary(notificationProvider);
if (notificationSummary.MissedCallCount > 99) notificationSummary.MissedCallCount = 99;
if (notificationSummary.EmailCount > 99) notificationSummary.EmailCount = 99;
if (notificationSummary.TextCount > 99) notificationSummary.TextCount = 99;
if (notificationSummary.VoiceCount > 99) notificationSummary.VoiceCount = 99;
if (notificationSummary.EmailCount > 0)
{
Debug.Print("Emails: " + notificationSummary.EmailCount.ToString());
screen.DrawImage(33, 0, EmailImage, 0, 0, EmailImage.Width, EmailImage.Height);
screen.DrawText(notificationSummary.EmailCount.ToString(), font, Color.White, 45, -2);
}
if (notificationSummary.TextCount > 0)
{
Debug.Print("Text: " + notificationSummary.TextCount.ToString());
screen.DrawImage(58, 0, TextImage, 0, 0, TextImage.Width, TextImage.Height);
screen.DrawText(notificationSummary.TextCount.ToString(), font, Color.White, 70, -2);
}
if (notificationSummary.VoiceCount > 0)
{
Debug.Print("Voice: " + notificationSummary.VoiceCount.ToString());
screen.DrawImage(83, 0, VoiceMailImage, 0, 0, VoiceMailImage.Width, VoiceMailImage.Height);
screen.DrawText(notificationSummary.VoiceCount.ToString(), font, Color.White, 95, -2);
}
if (notificationSummary.MissedCallCount > 0)
{
Debug.Print("Missed Calls: " + notificationSummary.MissedCallCount.ToString());
screen.DrawImage(106, 0, CalendarImage, 0, 0, CalendarImage.Width, CalendarImage.Height);
screen.DrawText(notificationSummary.MissedCallCount.ToString(), font, Color.White, 117, -2);
}
}