私はBitmapImage
を取り、分離ストレージ内のローカルのWindows Phone 7デバイス上のJPEGとして保存する機能を作成するために探しています:Windows Phone 7デバイスでビットマップイメージを取得し、JPEGイメージファイルとして保存するにはどうすればよいですか?
static public void saveImageLocally(string barcode, BitmapImage anImage)
{
// save anImage as a JPEG on the device here
}
私はこれを実現するにはどうすればよいですか?どういうわけか私はIsolatedStorageFile
を使ったと仮定していますか?
ありがとうございました。
編集:私はこれまでに発見したものをここ
は...誰もが、これはこれを行うには正しい方法であるかどうかを確認することができますか?それを保存するには
static public void saveImageLocally(string barcode, BitmapImage anImage)
{
WriteableBitmap wb = new WriteableBitmap(anImage);
using (var isf = IsolatedStorageFile.GetUserStoreForApplication())
{
using (var fs = isf.CreateFile(barcode + ".jpg"))
{
wb.SaveJpeg(fs, wb.PixelWidth, wb.PixelHeight, 0, 100);
}
}
}
static public void deleteImageLocally(string barcode)
{
using (IsolatedStorageFile MyStore = IsolatedStorageFile.GetUserStoreForApplication())
{
MyStore.DeleteFile(barcode + ".jpg");
}
}
static public BitmapImage getImageWithBarcode(string barcode)
{
BitmapImage bi = new BitmapImage();
using (var isf = IsolatedStorageFile.GetUserStoreForApplication())
{
using (var fs = isf.OpenFile(barcode + ".jpg", FileMode.Open))
{
bi.SetSource(fs);
}
}
return bi;
}