繁体   English   中英

从Windows Phone 8.1中的Image获取Jpeg属性

[英]Get Jpeg properties from Image in Windows Phone 8.1

我需要从手机图像库中获取的图像获取Jpeg属性。 在另一个XAML项目中,我可以使用

var myImage = System.Drawing.Image.FromStream(myImageStream);
foreach(var imageProperty in myImage.PropertyItems)
     //do things

我应该在Windows Phone 8.1中怎么做? 我需要具有ID 274(方向)的属性才能将图像旋转到正确的方向

首先,请确保允许访问您的应用程序清单中的图片库。

然后这段代码应该工作:

// First get the list of all your pictures in the pictures library
var allMyPictures = await KnownFolders.PicturesLibrary.GetFilesAsync();
// iterate trough your pictures
foreach (var file in allMyPictures)
{
    // Get all the properties
    var properties = await file.Properties.GetImagePropertiesAsync();
    // Get the orientation
    var orientation = properties.Orientation;
}

请注意,从手机摄像头拍摄的照片不会直接保存在图片库中,而是直接保存在子文件夹中(诺基亚手机上的“相机胶卷”)。 如果您的情况如此,则需要像这样适应:

// Get the Camera Roll subfolder
var cameraRollFolder = await KnownFolders.PicturesLibrary.GetFolderAsync("Camera Roll");
// Get all the pictures from this specific directory
var allMyPicturesFromCameraRoll = await cameraRollFolder.GetFilesAsync();

该代码已经在我的诺基亚635上进行了测试,但可以在任何Windows Phone 8上使用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM