现在主要是上传头像。。太大了要截取一部分
不会用C#里的drawing类。。自己不会写。
希望能提供代码。

解决方案 »

  1.   

    利用Image.GetThumbnailImage,造缩略图的。
    简例:
    Image.GetThumbnailImageAbort callback= new Image.GetThumbnailImageAbort(ThumbnailCallback); 
    Bitmap bmp= new Bitmap("1.jpg"); 
    Image img= bmp.GetThumbnailImage( nWidth, nHeight, callback, IntPtr.Zero); 
    e.Graphics.DrawImage(img, nWidth, nHeight); 
      

  2.   

    Image.GetThumbnailImageAbort callback= new Image.GetThumbnailImageAbort(ThumbnailCallback); 
    Bitmap bmp= new Bitmap("test.jpg"); 
    Image img= bmp.GetThumbnailImage( 200, 200, null, IntPtr.Zero); 把图版压缩成长和高都是200的图片;
    从数据库里显示压缩的图片
                        byte[] stillsData = (byte[])Dr0["Image"];
                        System.IO.Stream ms = new System.IO.MemoryStream(stillsData);
                        System.Drawing.Image photo = Image.FromStream(ms);   //得到图片  
                        this.pEVIPClientImage.Image = photo.GetThumbnailImage(200, 200, null, IntPtr.Zero);
                        ms.Close();
      

  3.   

    Bitmap oldImage(文件名);
    Bitmap newImage = new Bitmap(newWidth, newHeight, PixelFormat.Format32bppArgb);
    Graphics g = Graphics.FromImage(newImage);
    g.DrawImage(oldImage, startx, starty, newWIdth, newHeigh);
    newImage.Save
      

  4.   

    public void MakeSmallImg(System.Web.HttpPostedFile postFile, string saveImg, System.Double Width, System.Double Height)
        {        //SourcePhotoName
            string m_OriginalFilename = postFile.FileName;
            string m_strGoodFile = saveImg;        //GetPhotoObject From SourceFile
            System.Drawing.Image m_Image = System.Drawing.Image.FromStream(postFile.InputStream, true);        System.Double NewWidth, NewHeight;
                   NewWidth = 160;
            NewHeight = 120;        //GetPhotoSize
            System.Drawing.Size size = new System.Drawing.Size((int)NewWidth, (int)NewHeight);
            //The New of Bimp Photo
            System.Drawing.Image bitmap = new System.Drawing.Bitmap(size.Width, size.Height);
            // The New of Palette
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);
            // Set HightQuality Arithmetic For Graphics
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
            //设置高质量,低速度呈现平滑程度
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            //ClearCanvas
            g.Clear(System.Drawing.Color.White);
            //在指定位置画图 
            g.DrawImage(m_Image, new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height),
            new System.Drawing.Rectangle(0, 0, m_Image.Width, m_Image.Height),
            System.Drawing.GraphicsUnit.Pixel);        //SavePhoto Of HightFocus
            bitmap.Save(m_strGoodFile, System.Drawing.Imaging.ImageFormat.Jpeg);
            //DisposeRes
            g.Dispose();
            m_Image.Dispose();
            bitmap.Dispose();
        }这个不是很完整,生成160×120的,参数没用,楼主可以改一下按比例生成,很简单啊
      

  5.   

    截图代码,参考下,在from1里面放2个picturebox控件,事先添加一张图片到picturebox1上面
    在picturebox1截图后的图像就能显示在picturebox2上了
    using System.Drawing;private int _x, _y;
            Image _img = null;
            private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
            {
                _img = pictureBox1.Image.Clone() as Image;            _x = e.X;
                _y = e.Y; 
            }        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
            {
                int sx = _x < e.X ? _x : e.X;
                int sy = _y < e.Y ? _y : e.Y;
                int w = Math.Abs(_x - e.X);
                int h = Math.Abs(_y - e.Y);
                Graphics g = Graphics.FromHwnd(pictureBox2.Handle);
                g.Clear(pictureBox2.BackColor);
                g.DrawImage(pictureBox1.Image, new Rectangle(0, 0, w, h), sx, sy, w, h, GraphicsUnit.Pixel);         }        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    Pen p = new Pen(Color.Blue,1);
                    p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                    Graphics g = Graphics.FromHwnd(pictureBox1.Handle);
                    int sx = _x < e.X ? _x : e.X;
                    int sy = _y < e.Y ? _y : e.Y;
                    int w = Math.Abs(_x - e.X);
                    int h = Math.Abs(_y - e.Y);
                    pictureBox1.Image = _img;
                    g.DrawRectangle(p, sx, sy, w, h);
                }        }
      

  6.   

    顺便问下有没有web下的图片编辑,就跟涂鸦网样的。有人做过没?