silverlight 获取取Media图片

silverlight 获取取Media图片,第1张

概述界面: <Grid x:Name="LayoutRoot" ShowGridLines="True" Background="White"> <StackPanel Orientation="Horizontal" Margin="0,0,-117,0"> <Border Width="320" Height="240"

界面:

<GrID x:name="LayoutRoot" ShowGrIDlines="True" Background="White">        <StackPanel OrIEntation="Horizontal" margin="0,-117,0">            <border WIDth="320" Height="240"                    margin="5" borderBrush="Black"                    borderThickness="1">                    <MediaElement x:name="media" Source="medias/may.wmv"/>            </border>                        <border WIDth="160" Height="120"                    margin="5" borderBrush="Black"                                        borderThickness="1">                <Image x:name="CaptureImage1" Stretch="None"/>            </border>        </StackPanel>        <button Content="button" Height="23" HorizontalAlignment="left" margin="10,10,0" name="button1" VerticalAlignment="top" WIDth="75" />        <button Content="button" Height="23" HorizontalAlignment="left" margin="10,43,0" name="button2" VerticalAlignment="top" WIDth="75" />    </GrID>

后台:
  public MainPage()        {            InitializeComponent();            button1.Click += new RoutedEventHandler(CaptureImage);            button2.Click += new RoutedEventHandler(ModifyPixels);        }        private voID CaptureImage(object sender,RoutedEventArgs e)        {             //transform to scale the image by 50%            Scaletransform transform = new Scaletransform();            transform.ScaleX = .5;            transform.ScaleY = .5;                        //Get bitmap image from the current frame of vIDeo            WriteableBitmap bitmap = new WriteableBitmap(media,transform);            //Set the Image object,defined in XAML,to the new bitmap.            CaptureImage1.source = bitmap;        }        private voID ModifyPixels(object sender,RoutedEventArgs e)        {            //Get WriteableBitmap.            if (CaptureImage1.source != null)            {                WriteableBitmap bitmap = new WriteableBitmap((BitmapSource)CaptureImage1.source);                //Iterate through each pixel.                for (int x = 0; x < bitmap.Pixels.Length; x++)                {                     //Set every 4th pixel.                    if (x % 4 == 0)                    {                        bitmap.Pixels[x] = 0;                    }                }                //Set Image object,to the modifIEd bitmap.                CaptureImage1.source = bitmap;            }        }

总结

以上是内存溢出为你收集整理的silverlight 获取取Media图片全部内容,希望文章能够帮你解决silverlight 获取取Media图片所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1076828.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-26
下一篇2022-05-26

发表评论

登录后才能评论

评论列表(0条)

    保存