首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将WritableBitmap保存到IsolatedStorageFileStream

将WritableBitmap保存到IsolatedStorageFileStream
EN

Stack Overflow用户
提问于 2013-11-25 16:12:12
回答 1查看 105关注 0票数 1

有没有一种简单的方法可以将变量WriteableBitmap的内容保存到IsolatedStorageFile?我正在写一个程序,它处理图片中的像素,然后将处理后的位图保存为*.bmp文件,并将其存储在"saved WriteableBitmap“目录中。我有将WriteableBitmap保存为jpeg文件的代码,但正如我之前所说的,我不想以任何方式压缩图形。请帮我解决我的问题。

代码语言:javascript
复制
private void Save_as_bmp(object sender, RoutedEventArgs e)
    {



        String temp = "photo.bmp";

        using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
        {
            if (myIsolatedStorage.FileExists(temp))
            {
                myIsolatedStorage.DeleteFile(temp);
            }

            IsolatedStorageFileStream fileStream = myIsolatedStorage.CreateFile(tempJPEG);

            //Writeable wb declared in another method

            //JPEG compression  
            //wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 0, 100); 

            //  In this place I need to  save variable wb to file stream without any compression
            // something like - fileStram = wb.content;


            fileStream.Close();
        }


        using (IsolatedStorageFile myIsolatedStorage2 = IsolatedStorageFile.GetUserStoreForApplication())
        {
            using (IsolatedStorageFileStream fileStream2 = myIsolatedStorage2.OpenFile("photo.bmp", FileMode.Open, FileAccess.Read))
            {

                try
                {

                    var mediaLibrary2 = new MediaLibrary();
                    mediaLibrary2.SavePicture("raster_graphic", fileStream2);
                    //mediaLibrary2.SavePictureToCameraRoll("raster_graphic", fileStream2);
                    MessageBox.Show("Image saved");
                    //fileStream2.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error, exception: " + ex.Message);
                }
            }
        }



    }
EN

回答 1

Stack Overflow用户

发布于 2014-06-05 02:34:35

有两种方法可以做到这一点。简单的方式(implement this free dll called EZ_iso)或困难的方式。找出独立存储过程和所有边缘情况例外。

该链接上还有文档和源代码,所以如果您有兴趣学习如何自己做这件事,您可以从那里开始。

如果你实现了DLL,它会是这样的。

代码语言:javascript
复制
void CameraTaskCapture_Completed(object sender, PhotoResult e){ 
    //Doesn't have to be from camera capture. This is just the example from the documentation 
    //Just pass in a BitmapImage
    EZ_Iso.IsolatedStorageAccess.SaveImage(“MyImage”, e.ChosenPhoto); 
} 

然后这就是你检索它的方式

代码语言:javascript
复制
//This could also be a BitmapImage instead of an ImageControl.Source
ImageControl.Source = EZ_Iso.IsolatedStroageAccess.GetImage(“MyImage”,800,480);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20187527

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档