//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); }
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; } }
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); }
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); } }
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(); }
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; } }
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); } }
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 }
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 }
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); }
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); } } }
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); } }
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 ); } }
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); } }
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); } }
/// <summary> /// Draw one todo event on provided bitmap /// </summary> /// <param name="bitmap"></param> /// <param name="time"></param> public void DrawEvent(Bitmap bitmap, DateTime time) { // decide if it is time to use inverted colors if ((DueDate - time).Ticks < 150000000f) // blink last 15 seconds { _inverse = !_inverse; Blinking = true; } else if ((DueDate - time).Ticks < 60 * 150000000f) // show in inverted colors for last 15 minutes _inverse = true; else _inverse = false; // if bitmap is larger than 64 x 48 - create smaller one and copy back if (bitmap.Height != 48 || bitmap.Width != 64) { Bitmap smallBitmap = new Bitmap(64, 48); PaintEvent(smallBitmap, time); bitmap.DrawImage(32, 48, smallBitmap, 0, 0, 64, 48); } else PaintEvent(bitmap, time); }
/// <summary> /// Draw event on 64 x 48 bitmap /// </summary> /// <param name="bitmap">Bitmap to draw on</param> /// <param name="time">Current time</param> public void PaintEvent(Bitmap bitmap, DateTime time) { Font timeFont = Resources.GetFont(Resources.FontResources.ubuntu16c); Font smallFont = Resources.GetFont(Resources.FontResources.ubuntu12c); Painter painter = new Painter(bitmap); TimeSpan ts = DueDate - time; Bitmap todotypes; // draw separator bitmap.DrawLine(Color.White, 1, 0, 0, 64, 0); // if inverse draw background and use inverted icons if (_inverse) { bitmap.DrawRectangle(Color.White, 0, 0, 3, 64, 18, 0, 0, Color.White, 0, 0, Color.White, 64, 48, 0xFF); todotypes = new Bitmap(Resources.GetBytes(Resources.BinaryResources.todotypes_inverted), Bitmap.BitmapImageType.Gif); } else todotypes = new Bitmap(Resources.GetBytes(Resources.BinaryResources.todotypes), Bitmap.BitmapImageType.Gif); //// draw icon bitmap.DrawImage(0, 5, todotypes, 0, (int)Type * 16, 16, 16); if (ts.Days > 0) bitmap.DrawTextInRect( ts.Days + "days", 16, 0, 48, 18, Bitmap.DT_AlignmentCenter, _inverse?Color.Black:Color.White, timeFont ); else if ( ts.Days == 0 && ts.Minutes <= 0 ) bitmap.DrawTextInRect( "NOW!", 16, 0, 48, 20, Bitmap.DT_AlignmentCenter, _inverse ? Color.Black : Color.White, timeFont ); else bitmap.DrawTextInRect( ts.Hours + "h " + ts.Minutes + "m", 16, 0, 48, 20, Bitmap.DT_AlignmentCenter, _inverse ? Color.Black : Color.White, timeFont ); if (Label.Length > 0) { bitmap.DrawTextInRect(Label, 0, 19, 64, 30, Bitmap.DT_WordWrap|Bitmap.DT_TruncateAtBottom, Color.White, smallFont); } }
public override void Draw(Bitmap surface, int xOffset, int yOffset) { surface.DrawImage(xOffset, yOffset, _cache, 0, 0, 320, 240); if (_bonusItem != BonusItemType.None) { surface.DrawImage(112 + xOffset, 144 + yOffset, _mazeSpriteSheet, _bonusItemRect.X, _bonusItemRect.Y, _bonusItemRect.Width, _bonusItemRect.Height); } }
private void Draw(Bitmap surface, Picturebox host, int x, int y, int index) { Rect r = _frames[index]; surface.DrawImage(x, y, _texture, r.X, r.Y, r.Width, r.Height); }
public override void Render(Bitmap screen) { if (base._screen == null) _screen = screen; screen.DrawLine(Color.White, 2, 0, AGENT.Contrib.Device.Size/2 - 10, AGENT.Contrib.Device.Size, AGENT.Contrib.Device.Size/2 - 10); screen.DrawImage(0, AGENT.Contrib.Device.Size - monthGrid.Height, monthGrid, 0, 0, monthGrid.Width, monthGrid.Height); foreach (Day day in days) { if (day.Timestamp.Date == Settings.Now.Date) { screen.DrawRectangle(Color.White, 1, day.Point.X-2, day.Point.Y+1, 19, 11, 0, 0, Color.White, 0, 0, Color.White, 0, 0, 255); screen.DrawText(day.Text, font, Color.Black, day.Point.X, day.Point.Y); } else { screen.DrawText(day.Text, font, Color.White, day.Point.X, day.Point.Y); } } string date = Settings.Now.ToString(System.Globalization.DateTimeFormatInfo.CurrentInfo.LongDatePattern); screen.DrawText(date, font, Color.White, 5, 15); string dow = "Day: " + Settings.Now.DayOfYear.ToString(); screen.DrawText(dow.ToString(), font, Color.White, 5, 35); drawing.DrawTray(screen, _notificationProvider, smallFont); }
protected override void DrawItem(Bitmap screen, int x, int y, int width, int height, ref int index, object it, Style cStyle) { bool selected = _selIndex == index; FsItem item = (FsItem)it; if (selected) screen.DrawRectangle(Colors.Blue, 0, x, y, width, height, 0, 0, cStyle.ListBoxSelectedItemBack1, x, y, cStyle.ListBoxSelectedItemBack2, x, y + height, Enabled ? (ushort)256 : (ushort)128); Color textColor = _playing == it ? Colors.Green : (Enabled ? (selected ? cStyle.TextBoxPressedTextColor : cStyle.TextBoxEnabledTextColor) : cStyle.TextBoxDisabledTextColor); Bitmap toDraw = item.IsBack ? fsBack : (item.IsDirectory ? fsFolder : (item.IsMusicFile ? fsMusic : fsNone)); screen.DrawImage(x + 5, y + (ItemHeight - 16) / 2, toDraw, 0, 0, 16, 16); screen.DrawText(item.Name, nameFont, textColor, x + 26, y + (ItemHeight - nameFont.Height) / 2); }
public override void LoadContent() { _font = Resources.GetFont(Resources.FontResources.NinaB); var tempSheet = Resources.GetBitmap(Resources.BitmapResources.pacman); _spriteSheet = new Bitmap(tempSheet.Width, tempSheet.Height); _spriteSheet.DrawImage(0, 0, tempSheet, 0, 0, tempSheet.Width, tempSheet.Height); _spriteSheet.MakeTransparent(Microsoft.SPOT.Presentation.Media.Color.Black); _maze = new Maze(); _maze.Draw(Surface, Host); _pacman = new Player(_spriteSheet, _maze); #region Initialize Bonus Point Sprites _bonus200 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(80, 104, 16, 8) })); _bonus400 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(96, 104, 16, 8) })); _bonus800 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(112, 104, 16, 8) })); _bonus1600 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(128, 104, 16, 8) })); _bonus100 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(0, 112, 16, 8) })); _bonus300 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(16, 112, 16, 8) })); _bonus500 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(32, 112, 16, 8) })); _bonus700 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(48, 112, 16, 8) })); _bonus1000 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(64, 112, 20, 8) })); _bonus2000 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(84, 112, 20, 8) })); _bonus3000 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(106, 112, 20, 8) })); _bonus5000 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(128, 112, 16, 8) })); #endregion #region Initialize Ghosts _blinky = new Ghost(_spriteSheet, _maze, _pacman, 16, new Personality() { ScatterX = 13 * 16, ScatterY = -2 * 16, TargetOffsetX = 0, TargetOffsetY = 0, HouseX = 7 * 16, HouseY = 7 * 16, StartX = 7 * 16, StartY = 5 * 16 }); _blinky.CurrentDirection = Direction.Left; _pinky = new Ghost(_spriteSheet, _maze, _pacman, 32, new Personality() { ScatterX = 1 * 16, ScatterY = -2 * 16, TargetOffsetX = 4 * 16, TargetOffsetY = 0, HouseX = 6 * 16, HouseY = 7 * 16, StartX = 6 * 16, StartY = 7 * 16 }); _pinky.CurrentDirection = Direction.Left; _inky = new Ghost(_spriteSheet, _maze, _pacman, 48, new Personality() { ScatterX = 14 * 16, ScatterY = 15 * 16, TargetOffsetX = -3 * 16, TargetOffsetY = 0, HouseX = 7 * 16, HouseY = 7 * 16, StartX = 7 * 16, StartY = 7 * 16 }); _inky.CurrentDirection = Direction.Left; _clyde = new Ghost(_spriteSheet, _maze, _pacman, 64, new Personality() { ScatterX = 0 * 16, ScatterY = 15 * 16, TargetOffsetX = 0, TargetOffsetY = -2 * 16, HouseX = 8 * 16, HouseY = 7 * 16, StartX = 8 * 16, StartY = 7 * 16 }); _clyde.CurrentDirection = Direction.Left; #endregion _pacman.Enemies = new Ghost[] { _blinky, _pinky, _inky, _clyde }; #region Add objects to scene AddToScene(_showBonusCountDown); AddToScene(_showBonusScoreCountDown); AddToScene(_maze); AddToScene(_pacman); AddToScene(_blinky); AddToScene(_pinky); AddToScene(_inky); AddToScene(_clyde); #endregion _maze.LevelComplete += MazeLevelComplete; _showBonusCountDown.Expired += BonusCountDown_Expired; MessageService.Instance.Subscribe(typeof(Messages.PacmanDeadMessage), HandlePacmanDeadMessage); MessageService.Instance.Subscribe(typeof(Messages.PacmanAteGhostMessage), HandlePacmanAteGhostMessage); MessageService.Instance.Subscribe(typeof(Messages.AteBonusItemMessage), HandleAteBonusItem); base.LoadContent(); Reset(); }
private void UpdateHud(Bitmap surface, int score) { int y = 10; int x = 244; surface.DrawText("Level", _font, Colors.White, x, y); surface.DrawText(Level.ToString(), _font, Colors.White, x, y + 20); y += 45; surface.DrawText("Score", _font, Colors.White, x, y); surface.DrawText(score.ToString(), _font, Colors.White, x, y + 20); y += 45; surface.DrawText("Lives", _font, Colors.White, x, y); for (int i = 0; i < _pacman.Lives; ++i) surface.DrawImage(x + (i << 4), y + 20, _spriteSheet, 32, 0, 16, 16); }
public override void Run() { try { Bitmap scratch = new Bitmap( 64, 32 ); for(int x = 0; x < scratch.Width; x++) { for(int y = 0; y < scratch.Height; y++) { scratch.SetPixel( x, y, Utility.FromRGB( x * 255 / (scratch.Width), y * 255 / (scratch.Height), 255 - x * 255 / (scratch.Width) ) ); } } Bitmap bmp = new Bitmap( Dimensions.Width, Dimensions.Height ); Random rand = new Random(); for(int i = 0; i < 1000; 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 ); } }
public override void Run() { try { Bitmap bmp = new Bitmap( Dimensions.Width, Dimensions.Height ); Resources.BitmapResources[] bitmaps = new Resources.BitmapResources[] { Resources.BitmapResources.Outlook0, Resources.BitmapResources.Outlook1, Resources.BitmapResources.Outlook2, }; for(int i = 0; i < bitmaps.Length; i++ ) { Bitmap src = Resources.GetBitmap( bitmaps[i] ); bmp.DrawImage( 0, 0, src, 0, 0, src.Width, src.Height ); bmp.Flush(); Thread.Sleep( 3000 ); } Pass = true; } catch(Exception e) { UnexpectedException( e ); } }
public override void Run() { try { Bitmap bmp = new Bitmap( Dimensions.Width, Dimensions.Height ); Bitmap src = Resources.GetBitmap( Resources.BitmapResources.SPOTLOGO ); Random 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 < 1000; 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 ); } }
/// <summary> /// Draw an image at a specific points /// </summary> /// <param name="screen"></param> /// <param name="imageData"></param> /// <param name="imageType"></param> /// <param name="point"></param> public void DrawImageAtPoint(Bitmap screen, byte[] imageData, Bitmap.BitmapImageType imageType, Point point) { var img = new Bitmap(imageData, imageType); screen.DrawImage(point.X, point.Y, img, 0, 0, img.Height, img.Width); }
private void Refresh(Bitmap screen) { if (_weather == null) { Style cStyle = StyleManager.CurrentStyle; screen.DrawRectangle(cStyle.BackgroundColor, 0, ScreenLeft, ScreenTop, Width, Height, 0, 0, cStyle.BackgroundColor, 0, 0, cStyle.BackgroundColor, 0, 0, 256); screen.DrawTextInRect("No weather information, invalid location or no network connection available!", ScreenLeft + 20, ScreenTop + 30, Width - 40, Height - 60, Bitmap.DT_AlignmentCenter | Bitmap.DT_WordWrap, StyleManager.CurrentStyle.TextBoxEnabledInvalidBorder, Fonts.ArialItalic); } else { if (_remakeBuffer) { RemakeControlBuffer(); _remakeBuffer = false; } screen.DrawImage(ScreenLeft, ScreenTop, _buffer, 0, 0, _buffer.Width, _buffer.Height, (ushort)(Enabled ? 256 : 128)); } }
public override void Draw(Bitmap surface, Picturebox host) { surface.DrawImage(0, 0, _cache, 0, 0, 320, 240); if (_bonusItem != BonusItemType.None) { surface.DrawImage(112, 144, _mazeSpriteSheet, _bonusItemRect.X, _bonusItemRect.Y, _bonusItemRect.Width, _bonusItemRect.Height); } }