Esempio n. 1
0
 /// <summary>
 /// save the graph image as a bitmap
 /// </summary>
 /// <param name="filename">bitmap filename</param>
 public void SaveAsBitmap(String filename)
 {
     if (image != null)
     {
         Bitmap bmp = new Bitmap(screen_width, screen_height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
         BitmapArrayConversions.updatebitmap_unsafe(image, bmp);
         bmp.Save(filename);
     }
 }
Esempio n. 2
0
        public void SaveImage(string filename)
        {
            Bitmap bmp = new Bitmap(screen_width, screen_height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            BitmapArrayConversions.updatebitmap_unsafe(image, bmp);

            if (filename.ToLower().EndsWith(".jpg"))
            {
                bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg);
            }
            if (filename.ToLower().EndsWith(".bmp"))
            {
                bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Bmp);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// process the given image file
        /// </summary>
        /// <param name="filename">
        /// filename of the image to process <see cref="System.String"/>
        /// </param>
        /// <param name="edges_filename">
        /// filename to save edges image <see cref="System.String"/>
        /// </param>
        public void Update(string filename, string edges_filename)
        {
            if (File.Exists(filename))
            {
                Bitmap bmp = (Bitmap)Bitmap.FromFile(filename);
                byte[] img = new byte[bmp.Width * bmp.Height * 3];
                BitmapArrayConversions.updatebitmap(bmp, img);

                Update(img, bmp.Width, bmp.Height);

                Bitmap edges_bmp = new Bitmap(bmp.Width, bmp.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                BitmapArrayConversions.updatebitmap_unsafe(edgesImage, edges_bmp);
                if (edges_filename.ToLower().EndsWith("jpg"))
                {
                    edges_bmp.Save(edges_filename, System.Drawing.Imaging.ImageFormat.Jpeg);
                }
                if (edges_filename.ToLower().EndsWith("bmp"))
                {
                    edges_bmp.Save(edges_filename, System.Drawing.Imaging.ImageFormat.Bmp);
                }
            }
        }
Esempio n. 4
0
        /// <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);
        }