本文整理汇总了C#中Microsoft.Xna.Framework.Media.MediaLibrary.GetPictureFromToken方法的典型用法代码示例。如果您正苦于以下问题:C# MediaLibrary.GetPictureFromToken方法的具体用法?C# MediaLibrary.GetPictureFromToken怎么用?C# MediaLibrary.GetPictureFromToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Media.MediaLibrary
的用法示例。
在下文中一共展示了MediaLibrary.GetPictureFromToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
imageDetails.Text = "";
IDictionary<string, string> queryStrings =
NavigationContext.QueryString;
string token = null;
string source = null;
if (queryStrings.ContainsKey("token"))
{
token = queryStrings["token"];
source = "Photos_Extra_Viewer";
}
else if (queryStrings.ContainsKey("FileId"))
{
token = queryStrings["FileId"];
source = "Photos_Extra_Share";
}
if (!string.IsNullOrEmpty(token))
{
MediaLibrary mediaLib = new MediaLibrary();
Picture picture = mediaLib.GetPictureFromToken(token);
currentImage = ImageUtil.GetBitmap(picture.GetImage());
photoContainer.Fill = new ImageBrush { ImageSource = currentImage };
imageDetails.Text = string.Format("Image from {0}.\nPicture name:\n{1}\nMedia library token:\n{2}",
source, picture.Name, token);
}
imageDetails.Text += "\nUri: " + e.Uri.ToString();
}
示例2: OnNavigatedTo
// Sample code for building a localized ApplicationBar
//private void BuildLocalizedApplicationBar()
//{
// // Set the page's ApplicationBar to a new instance of ApplicationBar.
// ApplicationBar = new ApplicationBar();
// // Create a new button and set the text value to the localized string from AppResources.
// ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
// appBarButton.Text = AppResources.AppBarButtonText;
// ApplicationBar.Buttons.Add(appBarButton);
// // Create a new menu item with the localized string from AppResources.
// ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
// ApplicationBar.MenuItems.Add(appBarMenuItem);
//}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (State.ContainsKey("customCamera"))
{
State.Remove("customCamera");
InitializeCamera();
}
IDictionary<string, string> queryStrings = NavigationContext.QueryString;
string action = null;
if (queryStrings.ContainsKey("Action"))
action = queryStrings["Action"];
string token = null;
if (queryStrings.ContainsKey("FileId"))
token = queryStrings["FileId"];
if (!string.IsNullOrEmpty(token))
{
MediaLibrary mediaLib = new MediaLibrary();
Picture picture = mediaLib.GetPictureFromToken(token);
currentImage = PictureDecoder.DecodeJpeg(picture.GetImage());
photoContainer.Fill = new ImageBrush { ImageSource = currentImage };
imageDetails.Text = string.Format("Image from {0} action.\nPicture name:\n{1}\nMedia library token:\n{2}", action, picture.GetPath(), token);
}
}
示例3: OnNavigatedTo
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
// Get a dictionary of query string keys and values.
IDictionary<string, string> queryStrings = this.NavigationContext.QueryString;
// Check whether the app has been started by the photo edit picker of the Windows Phone System
// More information about the photo edit picker here: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202966(v=vs.105).aspx
if (queryStrings.ContainsKey("FileId") && imageAlreadyLoaded == false)
{
imageAlreadyLoaded = true;
// Retrieve the photo from the media library using the FileID passed to the app.
MediaLibrary library = new MediaLibrary();
Picture photoFromLibrary = library.GetPictureFromToken(queryStrings["FileId"]);
// Create a BitmapImage object and add set it as the PreviewImage
BitmapImage bitmapFromPhoto = new BitmapImage();
bitmapFromPhoto.SetSource(photoFromLibrary.GetPreviewImage());
SetPreviewImage(bitmapFromPhoto);
}
// Every time we navigate to the MainPage we check if a filter has been selected on the FilterView page
// If so, we apply this filter to the PreviewImage
if (FilterSelectorView.SelectedFilter != null)
{
await ApplyFilter(FilterSelectorView.SelectedFilter, PreviewPicture);
}
}
示例4: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Get a dictionary of query string keys and values.
IDictionary<string, string> queryStrings = this.NavigationContext.QueryString;
// Ensure that there is at least one key in the query string, and check whether the "FileId" key is present.
if (queryStrings.ContainsKey("FileId"))
{
// Retrieve the photo from the media library using the FileID passed to the app.
MediaLibrary library = new MediaLibrary();
Picture photoFromLibrary = library.GetPictureFromToken(queryStrings["FileId"]);
// Create a BitmapImage object and add set it as the image control source.
// To retrieve a full-resolution image, use the GetImage() method instead.
BitmapImage bitmapFromPhoto = new BitmapImage();
bitmapFromPhoto.SetSource(photoFromLibrary.GetPreviewImage());
image1.Source = bitmapFromPhoto;
}
}
示例5: OnNavigatedTo
/// <summary>
/// Called when this MainPage becomes the active page in a frame.
/// </summary>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (!bmp.IsLoaded)
{
Stream stream;
var query = this.NavigationContext.QueryString;
if (query.ContainsKey("token"))
{
MediaLibrary lib = new MediaLibrary();
Picture pic = lib.GetPictureFromToken(query["token"]);
stream = pic.GetImage();
}
else
{
Uri uri = new Uri("Images/lenna.jpg", UriKind.Relative);
stream = Application.GetResourceStream(uri).Stream;
}
bmp.Load(stream);
}
base.OnNavigatedTo(e);
}
示例6: OnActivate
protected override void OnActivate()
{
var library = new MediaLibrary();
var photoFromLibrary = library.GetPictureFromToken(FileId);
var image = photoFromLibrary.GetImage();
var buffer = LerTudo(image);
dadosDaMulta.ExibirImagem(image, true);
fileInfo = new HttpUpload.FileInfo
{
FileName = photoFromLibrary.Name,
ContentType = "image/jpeg",
Buffer = buffer,
ParamName = "multa[foto]"
};
dadosDaMulta.PropertyChanged += (sender, e) => { if (e.PropertyName == "IsValid") NotifyOfPropertyChange("CanShare"); };
base.OnActivate();
}
示例7: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Get a dictionary of query string keys and values.
IDictionary<string, string> queryStrings = this.NavigationContext.QueryString;
// Ensure that there is at least one key in the query string, and check whether the "token" key is present.
if (queryStrings.ContainsKey("token"))
{
// Retrieve the picture from the media library using the token passed to the application.
MediaLibrary library = new MediaLibrary();
Picture picture = library.GetPictureFromToken(queryStrings["token"]);
// Create a WriteableBitmap object and add it to the Image control Source property.
BitmapImage bitmap = new BitmapImage();
bitmap.CreateOptions = BitmapCreateOptions.None;
bitmap.SetSource(picture.GetImage());
// WriteableBitmap picLibraryImage = new WriteableBitmap(bitmap);
Image_ToBeUploaded.Source = bitmap;
}
}
示例8: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
if (NavigationContext.QueryString.ContainsKey("token"))
{
var library = new MediaLibrary();
Picture picture = library.GetPictureFromToken(NavigationContext.QueryString["token"]);
BitmapImage img = new BitmapImage() { CreateOptions = BitmapCreateOptions.None};
img.SetSource(picture.GetImage());
image.Source = img;
NavigationContext.QueryString.Remove("token");
}
else if (NavigationContext.QueryString.ContainsKey("Photo"))
{
if (bool.Parse(NavigationContext.QueryString["Photo"]))
image.Source = new BitmapImage(new Uri(instance.CurrentImage, UriKind.RelativeOrAbsolute));
else
{
task.Show();
NavigationContext.QueryString.Remove("Photo");
}
}
base.OnNavigatedTo(e);
}
示例9: TryInitPhoto
private void TryInitPhoto()
{
// Get a dictionary of query string keys and values.
IDictionary<string, string> queryStrings = Page.NavigationContext.QueryString;
// Ensure that there is at least one key in the query string, and check whether the "FileId" key is present.
if (queryStrings.ContainsKey(FileId))
{
string fileId = queryStrings[FileId];
MediaLibrary library = new MediaLibrary();
Picture photoFromLibrary = library.GetPictureFromToken(fileId);
InitImaging(null, fileId);
}
}
示例10: FromLibraryImage
public void FromLibraryImage(string token)
{
System.Diagnostics.Debug.Assert(token != null);
using (var library = new MediaLibrary())
{
using (var picture = library.GetPictureFromToken(token))
{
var libraryPath = picture.GetPath();
if (LibraryPath != libraryPath)
{
LibraryPath = libraryPath;
LocalPath = Mapping.MatchLibraryPathWithLocalPath(libraryPath);
if (LocalPath != null)
{
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
Image = store.OpenFile(LocalPath, FileMode.Open);
}
}
else
{
Image = picture.GetImage();
}
OriginalPath = Mapping.MatchPathWithOriginalPath(libraryPath);
if (OriginalPath != null)
{
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
Original = store.OpenFile(OriginalPath, FileMode.Open);
}
}
else
{
Original = null;
}
OriginalLibraryPath = null;
}
}
}
}
示例11: OnNavigatedTo
// Sample code for building a localized ApplicationBar
//private void BuildLocalizedApplicationBar()
//{
// // Set the page's ApplicationBar to a new instance of ApplicationBar.
// ApplicationBar = new ApplicationBar();
// // Create a new button and set the text value to the localized string from AppResources.
// ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
// appBarButton.Text = AppResources.AppBarButtonText;
// ApplicationBar.Buttons.Add(appBarButton);
// // Create a new menu item with the localized string from AppResources.
// ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
// ApplicationBar.MenuItems.Add(appBarMenuItem);
//}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (State.ContainsKey("customCamera"))
{
State.Remove("customCamera");
InitializeCamera();
}
IDictionary<string, string> queryStrings = NavigationContext.QueryString;
string fileId = null;
string source = null;
// Photos_Extra_Viewer is deprecated
//if (queryStrings.ContainsKey("token"))
//{
// token = queryStrings["token"];
// source = "Photos_Extra_Viewer";
//}
//else
if (queryStrings.ContainsKey("Action") && queryStrings.ContainsKey("FileId"))
{
fileId = queryStrings["FileId"];
source = queryStrings["Action"];
}
if (!string.IsNullOrEmpty(fileId))
{
MediaLibrary mediaLib = new MediaLibrary();
Picture picture = mediaLib.GetPictureFromToken(fileId);
currentImage = PictureDecoder.DecodeJpeg(picture.GetImage());
photoContainer.Fill = new ImageBrush { ImageSource = currentImage };
imageDetails.Text = string.Format("Image from {0}.\nPicture name:\n{1}\nMedia library token:\n{2}",
source, picture.Name, fileId);
}
}
示例12: FromToken
public async Task FromToken(string token)
{
using (var library = new MediaLibrary())
{
using (var picture = library.GetPictureFromToken(token))
{
await FromLibraryPath(picture.GetPath());
}
}
}
示例13: GetPictureByToken
public static Picture GetPictureByToken(string token)
{
var library = new MediaLibrary();
var photoFromLibrary = library.GetPictureFromToken(token);
return photoFromLibrary;
}
示例14: ImageManipulator
public ImageManipulator(string token, Image helper, int bsize)
{
// Retrieve the picture from the media library using the token passed to the application.
MediaLibrary library = new MediaLibrary();
Picture picture = library.GetPictureFromToken(token);
InitFromStream(picture.GetImage(), helper);
this.Radius = (int)((finalImage.PixelWidth * bsize) / helper.Width);
}
示例15: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Get a dictionary of query string keys and values.
IDictionary<string, string> queryStrings = this.NavigationContext.QueryString;
// Ensure that there is at least one key in the query string, and check whether the "token" key is present.
if (queryStrings.ContainsKey("token"))
{
// Retrieve the picture from the media library using the token passed to the application.
MediaLibrary library = new MediaLibrary();
Picture picture = library.GetPictureFromToken(queryStrings["token"]);
StartLoadingImage(picture.GetImage());
}
}