在我的WP8应用程序中,用户可以拍照并存储在我的sqlce数据库中。问题是需要通过互联网发送的图片的大小,并且图片的长度至少为4mb!更改照片尺寸Windows Phone 8
我需要减少图片在我的应用程序中捕获后的大小。
这里是我的代码:
private void camera_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK && e.Error == null)
{
image = new System.Windows.Media.Imaging.BitmapImage();
image.SetSource(e.ChosenPhoto);
Imagem.Source = image;
}
}
以获取图像的图像保存到我的SQLCE数据库,我用这个代码:
byte[] ConvertImage()
{
if (image == null) return null;
MemoryStream ms = new MemoryStream();
WriteableBitmap wb = new WriteableBitmap(image);
wb.SaveJpeg(ms, image.PixelWidth, image.PixelHeight, 0, 100);
return ms.ToArray();
}
甚至可以保存为JPEG格式时,在我看来,字节大小依然过大。
http://writeablebitmapex.codeplex.com/或http://developer.nokia.com/ lumia/nokia-apis/imaging让我们知道你是否需要特定代码 – FunksMaName 2014-11-06 16:58:17
@FunksMaName我已经在使用writeablebitmapex,但我不知道如何减小图片大小。 – 2014-11-06 17:15:57