当前位置: 首页>>代码示例>>C#>>正文


C# MediaLibrary.SavePicture方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Media.MediaLibrary.SavePicture方法的典型用法代码示例。如果您正苦于以下问题:C# MediaLibrary.SavePicture方法的具体用法?C# MediaLibrary.SavePicture怎么用?C# MediaLibrary.SavePicture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Media.MediaLibrary的用法示例。


在下文中一共展示了MediaLibrary.SavePicture方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnSalvar_Click

        private void btnSalvar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string _tmpImage = "tmpImage";
                string _msgMensagem = "Imagem grava com sucesso!";

                var store = IsolatedStorageFile.GetUserStoreForApplication();
                if (store.FileExists(_tmpImage)) store.DeleteFile(_tmpImage);

                IsolatedStorageFileStream _stream = store.CreateFile(_tmpImage);
                WriteableBitmap _writeImage = new WriteableBitmap(_imagetmp);

                Extensions.SaveJpeg(_writeImage, _stream, _writeImage.PixelWidth,
                    _writeImage.PixelHeight, 0, 100);
                _stream.Close();
                _stream = store.OpenFile(_tmpImage, System.IO.FileMode.Open,
                    System.IO.FileAccess.Read);

                MediaLibrary _mlibrary = new MediaLibrary();
                _mlibrary.SavePicture(_stream.Name, _stream);
                _stream.Close();

                btnSalvar.IsEnabled = false;
                lblStatus.Text = _msgMensagem;
            }
            catch (Exception error)
            {
                lblStatus.Text = error.Message;
            }
        }
开发者ID:lhlima,项目名称:CollaborationProjects,代码行数:31,代码来源:MainPage.xaml.cs

示例2: saveImageDataToLibrary

    public void saveImageDataToLibrary(string jsonArgs)
    {
        try
        {
            var options = JsonHelper.Deserialize<string[]>(jsonArgs);

            string imageData = options[0];
            byte[] imageBytes = Convert.FromBase64String(imageData);

            using (var imageStream = new MemoryStream(imageBytes))
            {
                imageStream.Seek(0, SeekOrigin.Begin);

                string fileName = String.Format("c2i_{0:yyyyMMdd_HHmmss}", DateTime.Now);
                var library = new MediaLibrary();
                var picture = library.SavePicture(fileName, imageStream);

                if (picture.Name.Contains(fileName))
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.OK,
                        "Image saved: " + picture.Name));
                }
                else
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR,
                        "Failed to save image: " + picture.Name));
                }
            }
        }
        catch (Exception ex)
        {
            DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ex.Message));
        }
    }
开发者ID:Jypy,项目名称:zmNinja,代码行数:34,代码来源:Canvas2ImagePlugin.cs

示例3: WebClientOpenReadCompleted

        void WebClientOpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            const string tempJpeg = "TempJPEG";
            var streamResourceInfo = new StreamResourceInfo(e.Result, null);

            var userStoreForApplication = IsolatedStorageFile.GetUserStoreForApplication();
            if (userStoreForApplication.FileExists(tempJpeg))
            {
                userStoreForApplication.DeleteFile(tempJpeg);
            }

            var isolatedStorageFileStream = userStoreForApplication.CreateFile(tempJpeg);

            var bitmapImage = new BitmapImage { CreateOptions = BitmapCreateOptions.None };
            bitmapImage.SetSource(streamResourceInfo.Stream);

            var writeableBitmap = new WriteableBitmap(bitmapImage);
            writeableBitmap.SaveJpeg(isolatedStorageFileStream, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight, 0, 85);

            isolatedStorageFileStream.Close();
            isolatedStorageFileStream = userStoreForApplication.OpenFile(tempJpeg, FileMode.Open, FileAccess.Read);

            // Save the image to the camera roll or saved pictures album.
            var mediaLibrary = new MediaLibrary();

            // Save the image to the saved pictures album.
            mediaLibrary.SavePicture(string.Format("SavedPicture{0}.jpg", DateTime.Now), isolatedStorageFileStream);

            isolatedStorageFileStream.Close();
        }
开发者ID:trilok567,项目名称:Windows-Phone,代码行数:30,代码来源:Page1.xaml.cs

示例4: capture

        public static Boolean capture(int quality)
        {
            try
            {
                PhoneApplicationFrame frame = (PhoneApplicationFrame)Application.Current.RootVisual;
                WriteableBitmap bitmap = new WriteableBitmap((int)frame.ActualWidth, (int)frame.ActualHeight);
                bitmap.Render(frame, null);
                bitmap.Invalidate();

                string fileName = DateTime.Now.ToString("'Capture'yyyyMMddHHmmssfff'.jpg'");
                IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
                if (storage.FileExists(fileName))
                    return false;

                IsolatedStorageFileStream stream = storage.CreateFile(fileName);
                bitmap.SaveJpeg(stream, bitmap.PixelWidth, bitmap.PixelHeight, 0, quality);
                stream.Close();

                stream = storage.OpenFile(fileName, FileMode.Open, FileAccess.Read);
                MediaLibrary mediaLibrary = new MediaLibrary();
                Picture picture = mediaLibrary.SavePicture(fileName, stream);
                stream.Close();

                storage.DeleteFile(fileName);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return false;
            }

            return true;
        }
开发者ID:miyabi,项目名称:CaptureScreen,代码行数:33,代码来源:CaptureScreen.cs

示例5: SaveToPhotoLibrary

 public static void SaveToPhotoLibrary(this Texture2D texture, string filename)
 {
     MemoryStream memoryStream = new MemoryStream();
     texture.SaveAsJpeg(memoryStream, texture.Width, texture.Height);
     memoryStream.Position = 0;
     MediaLibrary mediaLibrary = new MediaLibrary();
     mediaLibrary.SavePicture(filename, memoryStream);
     memoryStream.Close();
 }
开发者ID:uhealin,项目名称:asskicker,代码行数:9,代码来源:Texture2DExtensions.cs

示例6: ButtonSaveFile_Click

 private void ButtonSaveFile_Click(object sender, RoutedEventArgs e)
 {
     FileTransfer trans = ((FrameworkElement)sender).DataContext as FileTransfer;
     if (trans != null)
     {
         var library = new MediaLibrary();
         library.SavePicture(trans.FileName, trans.Bytes);
         MessageBox.Show("File saved to 'Saved Pictures'", "File Saved", MessageBoxButton.OK);
     }
 }
开发者ID:Hitchhikrr,项目名称:Voip,代码行数:10,代码来源:FileTransferPage.xaml.cs

示例7: GeoTagAddition

        public void GeoTagAddition()
        {
            var task = WaitLocation();
            task.Wait();
            var position = task.Result;
            Debug.WriteLine("pos: " + position.Coordinate.Longitude + " " + position.Coordinate.Latitude);
            var mediaLibrary = new MediaLibrary();

            int count = 0;
            foreach (string filename in TestFiles.GeotagTargetImages)
            {
                var image = TestUtil.GetResourceByteArray(filename);
                var originalMetadata = JpegMetaDataParser.ParseImage(image);
                var NewImage = MetaDataOperator.AddGeoposition(image, position);
                var newMetadata = JpegMetaDataParser.ParseImage(NewImage);
                try
                {
                    var pic = mediaLibrary.SavePicture(string.Format("Exif addition test_" + count + "_{0:yyyyMMdd_HHmmss}.jpg", DateTime.Now), NewImage);
                }
                catch (NullReferenceException) { }

                TestUtil.IsGpsDataAdded(originalMetadata, newMetadata);

                using (var imageStream = TestUtil.GetResourceStream(filename))
                {
                    originalMetadata = JpegMetaDataParser.ParseImage(imageStream);
                    var newImageStream = MetaDataOperator.AddGeoposition(imageStream, position);
                    try
                    {
                        var pic2 = mediaLibrary.SavePicture(string.Format("Exif addition test_" + count + "_stream_{0:yyyyMMdd_HHmmss}.jpg", DateTime.Now), newImageStream);
                    }
                    catch (NullReferenceException) { }
                    finally { newImageStream.Close(); }

                    TestUtil.IsGpsDataAdded(originalMetadata, newMetadata);
                    imageStream.Close();
                    newImageStream.Close();
                    count++;
                }
                GC.Collect(); // Saving many big images in short time, memory mey be run out and it may throws NullReferenceException.
            }
        }
开发者ID:naotaco,项目名称:NtImageLib,代码行数:42,代码来源:Geotag.cs

示例8: SaveMergebtn_click

 private void SaveMergebtn_click(object sender, RoutedEventArgs e)
 {
     using (MemoryStream stream = new MemoryStream())
     {
         wb.SaveJpeg(stream, wb.PixelWidth, wb.PixelHeight, 0, 100);
         stream.Seek(0, SeekOrigin.Begin);
         using (MediaLibrary mediaLibrary = new MediaLibrary())
             mediaLibrary.SavePicture("Picture.jpg", stream);
     }
     MessageBox.Show("Picture Saved to media library...");
 }
开发者ID:trilok567,项目名称:Windows-Phone,代码行数:11,代码来源:MergeImageVsText.xaml.cs

示例9: SaveToMediaLibrary

 /// <summary>
 /// Saves the WriteableBitmap encoded as JPEG to the Media library.
 /// </summary>
 /// <param name="bitmap">The WriteableBitmap to save.</param>
 /// <param name="name">The name of the destination file.</param>
 /// <param name="quality">The quality for JPEG encoding has to be in the range 0-100, 
 /// where 100 is the best quality with the largest size.</param>
 /// <param name="saveToCameraRoll">If true the bitmap will be saved to the camera roll, otherwise it will be written to the default saved album.</param>
 public static Picture SaveToMediaLibrary(this WriteableBitmap bitmap, string name, int quality, bool saveToCameraRoll = false)
 {
    using (var stream = new MemoryStream())
    {
       // Save the picture to the WP media library
       bitmap.SaveJpeg(stream, bitmap.PixelWidth, bitmap.PixelHeight, 0, quality);
       stream.Seek(0, SeekOrigin.Begin);
       var mediaLibrary = new MediaLibrary();
       return saveToCameraRoll ? mediaLibrary.SavePictureToCameraRoll(name, stream) : mediaLibrary.SavePicture(name, stream);
    }
 }
开发者ID:Narinyir,项目名称:WriteableBitmapEx,代码行数:19,代码来源:WriteableBitmapWindowsPhoneXnaExtensions.cs

示例10: Save_Click

 /// <summary>
 /// Salva a imagem na biblioteca de imagens
 /// </summary>
 private void Save_Click(object sender, RoutedEventArgs e)
 {
     MediaLibrary library = new MediaLibrary();
     WriteableBitmap bitMap = new WriteableBitmap(drawCanvas, null);
     MemoryStream ms = new MemoryStream();
     Extensions.SaveJpeg(bitMap, ms, bitMap.PixelWidth,
                         bitMap.PixelHeight, 0, 100);
     ms.Seek(0, SeekOrigin.Begin);
     library.SavePicture(string.Format("Images\\{0}.jpg",
                                        Guid.NewGuid()), ms);
     New_Click(sender, e);
 }
开发者ID:RafasTavares,项目名称:AppTaskXamarin,代码行数:15,代码来源:PageAssinatura.xaml.cs

示例11: Button_Click_2

 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     WriteableBitmap writeableBitmap = new WriteableBitmap(480, 800);
     writeableBitmap.Render(App.Current.RootVisual, null);
     writeableBitmap.Invalidate();
     MemoryStream memoryStream = new MemoryStream();
     writeableBitmap.SaveJpeg(memoryStream, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight,0, 100);
     memoryStream.Seek(0, SeekOrigin.Begin);
     MediaLibrary mediaLibrary = new MediaLibrary();
     mediaLibrary.SavePicture(Guid.NewGuid().ToString() + ".jpg", memoryStream);
     memoryStream.Close();
 }
开发者ID:peepo3663,项目名称:WindowsPhone8,代码行数:12,代码来源:MainPage.xaml.cs

示例12: SaveButton_OnClick

 private void SaveButton_OnClick(object sender, EventArgs e)
 {
     if (!_canPress) return;
     string path = EditingLockscreenFilename + ".jpg";
     using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
     {
         var stream = storage.OpenFile(path, FileMode.Open);
         var library = new MediaLibrary();
         library.SavePicture("test", stream);
         stream.Close();
     }
 }
开发者ID:huucp,项目名称:AnimeWallpaperWP,代码行数:12,代码来源:ImageDetailPage.xaml.cs

示例13: btnSaveImage_Click

		private void btnSaveImage_Click (object sender, RoutedEventArgs e)
		{
			WriteableBitmap bitmap = signatureView.GetImage ();

			using (MemoryStream stream = new MemoryStream ()) {
				bitmap.SaveJpeg (stream, bitmap.PixelWidth, bitmap.PixelHeight, 0, 100);
				stream.Seek (0, SeekOrigin.Begin);

				using (MediaLibrary mediaLibrary = new MediaLibrary ())
					mediaLibrary.SavePicture ("signature.jpg", stream);
			}
			MessageBox.Show ("Picture saved to photo library");
		}
开发者ID:ronrat,项目名称:SignaturePad,代码行数:13,代码来源:MainPage.xaml.cs

示例14: btnSave_Click

        private void btnSave_Click(object sender, EventArgs e)
        {
            // Grid から Jpeg 保存用ストリームを作成
            WriteableBitmap wp = new WriteableBitmap(imgGrid, null);
            MemoryStream stream = new MemoryStream();
            wp.SaveJpeg(stream, wp.PixelWidth, wp.PixelHeight, 0, 100);

            // PictureHub に保存する
            using (MediaLibrary lib = new MediaLibrary()) {
                lib.SavePicture("PhotoEffect-" + DateTime.Now.ToString("yyyyMMddhhmmss"), stream.ToArray());
                MessageBox.Show("保存しました");
            }
        }
开发者ID:ktsutsu,项目名称:PhotoEffect,代码行数:13,代码来源:MainPage.xaml.cs

示例15: PageMethod1

        // Constructor
        public PageMethod1()
        {
            InitializeComponent();

            CameraButtons.ShutterKeyPressed += (s, e) =>
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    var bmp = new WriteableBitmap(displayImage, null);
                    var sout = new MemoryStream();
                    bmp.SaveJpeg(sout, bmp.PixelWidth, bmp.PixelHeight, 0, 70);
                    sout.Seek(0, SeekOrigin.Begin);

                    using (MediaLibrary mediaLibrary = new MediaLibrary())
                        mediaLibrary.SavePicture(String.Format("PictureNavigation Method1 {0:yyyyMMdd-HHmmss}", DateTime.Now), sout);
                });




            };


            Loaded += (s, e) =>
            {
                method.Output = displayImage;


                DispatcherTimer timer = new DispatcherTimer();
                timer.Tick += (ss, ee) =>
                {
                    const string total = "DeviceTotalMemory";
                    const string current = "ApplicationCurrentMemoryUsage";
                    const string peak = "ApplicationPeakMemoryUsage";

                    var currentBytes = ((long)DeviceExtendedProperties.GetValue(current)) / 1024.0 / 1024.0;


                    var txt = string.Format("Memory  = {0,5:F} MB / {1,5:F} MB\n", currentBytes, DeviceStatus.ApplicationMemoryUsageLimit / 1024 / 1024);
                    displayInfo.Text = txt + method.Info();




                };
                timer.Interval = new TimeSpan(0, 0, 0, 0, 40);
                timer.Start();


            };
        }
开发者ID:Nokia-Developer-Community-Projects,项目名称:wp8-sample,代码行数:52,代码来源:PageMethod1.xaml.cs


注:本文中的Microsoft.Xna.Framework.Media.MediaLibrary.SavePicture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。