当前位置: 首页 > 编程语言 > C#

如何在WindowsPhone中减小图像大小Share

时间:2023-04-11 00:50:37 C#

如何在WindowsPhone中减小图像大小我想将我的应用程序移植到WindowsPhone中。我必须在服务器上上传一张图片,所以它是小尺寸上传我已经在Widows中成功完成了但是问题是当我失败时..这是我的WindowsApp代码publicvoidCompressImage(inti,intj){bmp1.SetPixel(j,i,Color.FromArgb(bmp.GetPixel(j,i).R,bmp.GetPixel(j,i).G,bmp.GetPixel(j,i).B));}privatevoidbLoadImage_Click(objectsender,EventArgse){OpenFileDialogfile=newOpenFileDialog();if(file.ShowDialog()==DialogResult.OK){pictureBox1.Image=newBitmap(file.FileName);}}privatevoidbCompression_Click(objectsender,EventArgse){bmp=newBitmap(pictureBox1.Image);bmp1=newBitmap(bmp.Width,bmp.Height);for(inti=1;i0){res=resList.ElementAt(0);cam.Resolution=res;此示例选择您可以尝试的第一个分辨率。这个对我有用。它将我的9.70MB文件减少到270KB。WriteableBitmapcameraCapturedImage=PictureDecoder.DecodeJpeg(e.ChosenPhoto,1024,1024);使用(IsolatedStorageFileStreammyFileStream=myStore.CreateFile(fileName)){System.Windows.Media.Imaging.Extensions.SaveJpeg(cameraCapturedImage,myFileStream.PameraImage,cameraCapelWed.PixelHeight,0,85);我的文件流.Close();}注意:fileName是保存缩小尺寸图像的文件名。以上是C#学习教程:如何在Windows手机中缩小图片尺寸。如果对你有用,需要进一步了解C#学习教程,希望大家多多关注。本文收集自网络,不代表立场。涉及侵权,请点击维权联系管理员删除。如需转载请注明出处: