Web Analytics Made Easy -
StatCounter How to save bmp (image) to file - CodingForum

Announcement

Collapse
No announcement yet.

How to save bmp (image) to file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to save bmp (image) to file

    private void add_Video_Image(string sFullname_Path_of_Video)
    {
    //*create mediaplayer in memory and jump to position
    MediaPlayer mediaPlayer = new MediaPlayer();

    mediaPlayer.MediaOpened += new EventHandler(mediaplayer_OpenMedia);
    mediaPlayer.ScrubbingEnabled = true;
    mediaPlayer.Open(new Uri(sFullname_Path_of_Video));
    mediaPlayer.Position = TimeSpan.FromSeconds(0);
    }

    private void mediaplayer_OpenMedia(object sender, EventArgs e)
    {
    MediaPlayer mediaPlayer = sender as MediaPlayer;
    DrawingVisual drawingVisual = new DrawingVisual();
    DrawingContext drawingContext = drawingVisual.RenderOpen();
    drawingContext.DrawVideo(mediaPlayer, new Rect(0, 0, 160, 100));
    drawingContext.Close();

    double dpiX = 1 / 200;
    double dpiY = 1 / 200;
    RenderTargetBitmap bmp = new RenderTargetBitmap(160, 100, dpiX, dpiY, PixelFormats.Pbgra32);
    bmp.Render(drawingVisual);

    Image newImage = new Image();
    newImage.Source = bmp;
    newImage.Stretch = Stretch.Uniform;
    newImage.Height = 100;

    //save bmp to image
    }
Working...
X