public void SaveMotionModel( string filename, float map_tx_mm, float map_ty_mm, float map_bx_mm, float map_by_mm, bool clear) { motion.Show( map, map_image_width, map_image_width, map_tx_mm, map_ty_mm, map_bx_mm, map_by_mm, true, false, clear); BitmapArrayConversions.updatebitmap_unsafe(map, map_bitmap); if (filename.EndsWith("jpg")) { map_bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg); } if (filename.EndsWith("bmp")) { map_bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Bmp); } if (filename.EndsWith("png")) { map_bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Png); } if (filename.EndsWith("gif")) { map_bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Gif); } }
/// <summary> /// add some text to the given image /// </summary> /// <param name="img">colour image into which to insert th text</param> /// <param name="img_width">width of the image</param> /// <param name="img_height">height of the image</param> /// <param name="text">text to be added</param> /// <param name="font">font style</param> /// <param name="font_size">font size</param> /// <param name="r">red</param> /// <param name="g">green</param> /// <param name="b">blue</param> /// <param name="position_x">x coordinate at which to insert the text</param> /// <param name="position_y">y coordinate at which to insert the text</param> public static void AddText(byte[] img, int img_width, int img_height, String text, String font, int font_size, int r, int g, int b, float position_x, float position_y) { Bitmap screen_bmp = new Bitmap(img_width, img_height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); // insert the existing image into the bitmap BitmapArrayConversions.updatebitmap_unsafe(img, screen_bmp); Font drawFont = new Font(font, font_size); SolidBrush drawBrush = new SolidBrush(Color.FromArgb(r, g, b)); Graphics grph = Graphics.FromImage(screen_bmp); grph.DrawString(text, drawFont, drawBrush, position_x, position_y); grph.Dispose(); // extract the bitmap data BitmapArrayConversions.updatebitmap(screen_bmp, img); }