void camera_BitmapStreamed(Camera sender, Bitmap bitmap) { if (!picTimeout.IsRunning && GT.Timer.GetMachineTime() >= webcamStreamStopTime) { //Debug.Print("Stopping bitmap streaming"); camera.StopStreamingBitmaps(); } if (responders.Count > 0) { byte[] bmpFile = new byte[bitmap.Width * bitmap.Height * 3 + 54]; GHI.Premium.System.Util.BitmapToBMPFile(bitmap.GetBitmap(), bitmap.Width, bitmap.Height, bmpFile); GT.Picture picture = new GT.Picture(bmpFile, GT.Picture.PictureEncoding.BMP); numresponses++; Debug.Print("Sending webcam response " + numresponses + " to " + responders.Count + " clients"); foreach (HomeOSGadgeteer.Networking.Responder responder in responders) { try { responder.Respond(picture); } catch { } } responders.Clear(); } if (picTimeout.IsRunning) { oledDisplay.SimpleGraphics.DisplayImage(lastBitmap, 0, 0); oledDisplay.SimpleGraphics.Redraw(); Debug.Print("Picture streamed -> screen"); } }
public static bool SetBootLogo(Bitmap logo, int x, int y) { if (Utils.IsEmulator) return false; if (logo != null) { // New settings were saved, must reboot // The start-up logo will take effect after the first reset bool res = Configuration.StartUpLogo.Set(logo.GetBitmap(), x, y); Thread.Sleep(1000); // to set logo bitmap Configuration.StartUpLogo.Enabled = true; return res; //return Configuration.StartUpLogo.Set(logo.GetBitmap(), (int)(ScreenWidth - logo.Width) / 2, (int)(ScreenHeight - logo.Height) / 2); } else { if (Configuration.StartUpLogo.Enabled) { Configuration.StartUpLogo.Enabled = false; return true; } else return false; } }
/// <summary> /// Constructs a TinyBitmap from a preexisting bitmap. /// </summary> /// <param name="bitmap">The bitmap to construct from.</param> public TinyBitmap(Bitmap bitmap) { this.Width = (uint)bitmap.Width; this.Height = (uint)bitmap.Height; this.Data = new byte[this.Width * this.Height * 2]; Util.BitmapConvertBPP(bitmap.GetBitmap(), this.Data, Util.BPP_Type.BPP16_BGR_BE); }
public Image(Bitmap imageBMP) { image_data = new byte[imageBMP.Width * imageBMP.Height * 2]; GHI.OSHW.Hardware.Util.BitmapConvertBPP(imageBMP.GetBitmap(), image_data, GHI.OSHW.Hardware.Util.BPP_Type.BPP16_RGB_BE); image_width = (ushort)imageBMP.Width; image_height = (ushort)imageBMP.Height; }
void seePicture_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder) { if (pic != null) { Bitmap b = new Bitmap(320, 240); b.DrawLine(Colors.Red, 20, 0, 0, 319, 239); byte[] buff = new byte[320 * 240 * 3 + 54]; GHIElectronics.NETMF.System.Util.BitmapToBMPFile(b.GetBitmap(), 320, 240, buff); GT.Picture picture = new GT.Picture(buff, GT.Picture.PictureEncoding.BMP); responder.Respond(picture); } else responder.Respond("Take picture first"); }
/// <summary> /// Draws an image to the screen. /// </summary> /// <param name="bmp">The bitmap to be drawn to the screen</param> /// <param name="x">Starting X position of the image.</param> /// <param name="y">Starting Y position of the image.</param> public void Draw(Bitmap bmp, uint x = 0, uint y = 0) { if (Module.Mainboard.NativeBitmapConverter == null) Module.Mainboard.NativeBitmapConverter = new Mainboard.BitmapConvertBPP(BitmapConverter); byte[] rawData = new byte[bmp.Width * bmp.Height * 2]; Module.Mainboard.NativeBitmapConverter(bmp.GetBitmap(), rawData, Mainboard.BPP.BPP16_BGR_BE); DrawRaw(rawData, (uint)bmp.Width, (uint)bmp.Height, x, y); }