How do you integrate a PictureBox to display a video through WPF?
You probably don't want to use PictureBox to display images in WPF because it's a Windows Forms control and therefore suffers from interop limitations.
To display an image in WPF, use the Image element. Set its Source to be, typically, a BitmapImage whose UriSource is the URI of the bitmap file (which might be on the file system). (You can use another ImageSource type if that's an easier way to interface with the webcam.)
To display video, use the MediaElement element. To display a video file, set MediaElement's Source property to the URI of the video (which again might be on the file system). If you need to pull images from the webcam in order to form the video, you need to use the MediaElement in "clock mode," which is described in the MediaElement class topic in MSDN. See also "Multimedia Overview" in the WPF SDK (http://msdn.microsoft.com/en-us/library/aa970915.aspx).
Also try WPF MediaKit. The WPF MediaKit has a VideoCaptureElement control for WebCam support!
Related
There are a quite a few of sources to get a video stream from webcam into a picturebox embedded in a userform.
Preview a camera in DirectShow and capture a still image - in VB.net
How do i use attached webcams to take still image in my application
However, I am trying to do something a little neater, basically have a the preview of the video stream from webcam in a control that is embedded directly into the sheet rather than on a floating userform. I am not sure if this possible. I would very much appreciate any pointers.
(Answer from TnTinMn's comment - Posting as an answer to remove from 'Unanswered' queue)
If you can write a .Net WinForm UserControl to view your video stream, then you should be able to produce a ActiveX UserControl that you can utilize in Excel.
Get the Microsoft InteropForms Toolkit 2.1 .
Even though it was originally intended to allow .Net UC usage in VB6, it works fine to write UCs for use in Excel.
As a test, I just wrote one that used the Windows Media Player and it played the video fine as a UserControl on the worksheet.
Start VS as an Admin as it needs to be able to register the control.
I would say build a Form with TopMost = True
Then you can display your webcam video in this Form
and put it anywhere you want.
I have search so much on this topic and I couldn't find a way to draw a text on image or even a create an image and then draw a text in windows store app.
Is there way to load image from ms-appx:///Assets/image.png and write a text on the center of the image that passes somehow and save it into ms-appdata:///roaming/image11.png?
Use RenderTargetBitmap - this article has a pretty good explanation for Windows Store apps: http://social.technet.microsoft.com/wiki/contents/articles/20648.using-the-rendertargetbitmap-in-windows-store-apps-with-xaml-and-c.aspx.
If you meant WPF, it's similar: http://wpftutorial.net/BitmapFromVisual.html (just create a image control with textbox for the Visual)
My question is easy: Is it possible to create an animated GIF file from a Windows Phone app (7.8 or 8, or both) using C# ?
I searched on the internet for this and I found these tutorials:
http://bloggingabout.net/blogs/rick/archive/2005/05/10/3830.aspx
http://www.codeproject.com/Articles/11505/NGif-Animated-GIF-Encoder-for-NET
They are really cool and work perfectly for desktop app, but I can't make them work on a Windows Phone app, many classes are unavailable and I can't find a workaround. Is it really impossible to create a GIF file from images on a Windows Phone ? Is it due to the devices limitations ?
Thanks
Ok i don't know how far Ill be able to help. But if you are facing limitations in displaying a gif Image then you can use a nuget package named image tools
Blog for Image tools
And on the other hand if you want to display a number of images then I can suggest a work around. But it will be app specific.
use storyboards or timers to continiously animate an Image object or a Grid back ground.
Creating an image I guess is not possible due to device limitation
still if you have a sprite image
then you can use
<ImageBrush.Transform>
<TranslateTransform X="-380" Y="200" x:Name="tfDieImage"></TranslateTransform>
</ImageBrush.Transform>
Transforms to animate the image at regular intervals by changing the X and Y :)
In fact there is a very interesting way to create animated GIF. It is from VB6 days.
Just create every frame as separate GIF file with same color palette (this is the tricky part). strip GIF header from files except first file and then concatenate them with following magic 0x0021F9.
Animated GIF format is actually an extension to the GIF format so, application does not understand animated GIF can still be able to display first frame. As far as I remember that each frame can have its own color table, but I do not remember how.
The real trick is to create series of images sharing same color palette, which I haven't done it before. I just used this to load animated GIFs.
Why don't you try to do it by yourself? GIF format now is free, so if you need only to create GIF files, you can just implement specification or only part of it.
http://www.w3.org/Graphics/GIF/spec-gif89a.txt
Ok.
I will suggest you one post that shows that how to display a GIF formatted pictures or Animated pictures in windows phone.
Please Refer this link.
Show OR Create the GIF kind Images in windows phone.
This shows that there is like a GIF image but actually there is not a GIF but its a multiple jpeg files Array.
I hope you get the Solution.
Good Luck.
I am trying to show NON ANIMATED gif images in my WinRT app. My current solution is to use a server side converter to convert the images to png, and then load them into an Image control. I have limited bandwidth and would prefer to do it in-app. I used .Net Image Tools to do this on Windows Phone, but it does not appear to be available for Windows RT. I cannot show the images in a WebView because I need to show another element over the image. I know this is a duplicate of this, but that was closed by users who thought it was a duplicate of a question asking about showing animated gifs. My question is how to show NON ANIMATED gifs, and I can't seem to delete the old question.
You can use the gif directly in XAML within the <Image> element. There is no need to convert it. Just set the Source attribute to the image.
Is there a way to embed a youtube video into a MediaElement and save the video? I know that once you have an object inside your application you can have some sort of control over it(I think). If I'm correct, is it possible to save the youtube video once it is embedded inside the MediaElement? Thanks.
Youtube videos are not available as files, as they are streams. that makes it a bit hard to save them (Actually you can, JDownloader does that, but that's infringement of YT terms), but for playback, check this guide.
You can use webcontrol for it. set the source property to use the embed link of the video. it will work fine.
<WebBrowser Source="https://www.youtube-nocookie.com/embed/W152nHe9rkM?rel=0&showinfo=0" />