Phone中减小图像大小

Phone中减小图像大小

本文介绍了如何在Windows Phone中减小图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的应用程序移植到 Windows Phone 中.我必须在服务器上上传一个图像所以它是小尺寸的上传我已经成功地在寡妇中完成了这件事但问题是当我失败时..这是我的Windows应用程序代码

I am trying to port my app in windows phone . i have to upload an image on server So it is in small Size For uploading i have done this thing in Widows Successfully but problem is when i failed in it .. here is my code for windows App

public void CompressImage(int i, int j)
        {
            bmp1.SetPixel(j, i, Color.FromArgb(bmp.GetPixel(j, i).R, bmp.GetPixel(j, i).G, bmp.GetPixel(j, i).B));
        }



        private void bLoadImage_Click(object sender, EventArgs e)
        {
            OpenFileDialog file = new OpenFileDialog();
            if (file.ShowDialog() == DialogResult.OK)
            {
                pictureBox1.Image = new Bitmap(file.FileName);
            }
        }


        private void bCompression_Click(object sender, EventArgs e)
        {
            bmp = new Bitmap(pictureBox1.Image);
            bmp1 = new Bitmap(bmp.Width, bmp.Height);
            for (int i = 1; i < bmp.Height; i++)
                for (int j = 1; j < bmp.Width; j++)
                {
                    CompressImage(i, j);
                }
            pictureBox2.Image = bmp1;
            bmp1.Save("Picture.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
        }

在谷歌上搜索后,我发现 Windows Phone 不支持位图 .. 知道我如何在 Windows Phone 或任何其他替代方法中做同样的事情

After Searching on google i found out that windows Phone does not support Bitmap .. any idea how i can do the same thing in windows phone or any other alternative for doing this

推荐答案

您应该使用 WriteablBitmap 来减小图像的大小.WriteablBitmap 有许多 Windows 手机图像的方法这里是关于 writeablebitmapex 的更多信息.

You should use WriteablBitmap to reduce size of image. WriteablBitmap has number of methods for images in windows phone Here is more about writeablebitmapex.

这篇关于如何在Windows Phone中减小图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 15:53