调整位图图像 wp7 的大小
如何让它在 WP7 上运行?
private static Bitmap ResizeBitmap(Bitmap sourceBMP, int width, int height)
{
Bitmap result = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage(result))
g.DrawImage(sourceBMP, 0, 0, width, height);
return result;
}
How to get this working on WP7?
private static Bitmap ResizeBitmap(Bitmap sourceBMP, int width, int height)
{
Bitmap result = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage(result))
g.DrawImage(sourceBMP, 0, 0, width, height);
return result;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这就是我缩小从媒体库中选择的或用相机拍摄的图像的方法,希望它有所帮助。它保持纵横比。
This is how I scale down an image selected from the medialibrary or taken with the camera, hope it helps. It keeps the aspect ratio.
您还没有真正准确地描述您想要什么,您只是想在屏幕上渲染图像更大/更小吗?或访问调整大小的图像的像素值?
Image
元素并根据需要设置其Width
/Height
即可。该框架将负责为您扩展它。WriteableBitmap
。You haven't really described exactly what you want, do you just want to render the image bigger / smaller on the screen? or access the pixel values of a resized image?
Image
element and set itsWidth
/Height
as desired. The framework will take care of scaling it for you.WriteableBitmap
from the scaled image described in (1).这就是我如何将图像大小减小到小于 512 kb 并将图像保存在独立存储中,
注意:只是 Windows Phone 的初学者,所以请忍受我编码的方式
private void PhotoChooserTaskCompleted(object sender, PhotoResult e)
{
if (e.TaskResult != TaskResult.OK) 返回;
在此方法中,我传递 e.choosen 流及其文件名
,并将调整大小的图像(图像大小减少到小于 512 kb)保存在独立存储中,希望这对您有帮助,
private void SaveToIsolatedStorage(Stream imageStream, string fileName)
{
尝试
{
使用 (IsolatedStorageFile myIsolatedStorage =isolatedStorageFile.GetUserStoreForApplication())
{
希望这是有帮助的
This is How i have reduced the Image size that too less than 512 kb and saving image in Isolated storage,
Caution: Just a beginner in windows phone so pls bear the way i code
private void PhotoChooserTaskCompleted(object sender, PhotoResult e)
{
if (e.TaskResult != TaskResult.OK) return;
Here in this Method i m passing the stream that is e.choosen and its file name
and saving resized image (images size reducing less than 512 kb) in Isolated Storage, hope this helps you,
private void SaveToIsolatedStorage(Stream imageStream, string fileName)
{
try
{
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
hope this was helpFull