那你用Bitmap.Save或Image.Save不就行了

解决方案 »

  1.   

    能说的再详细点吗?现在我在一个panel上画了一些控件,并编辑了相应事件,我要完成把这些东西存储,下次再调出继续编辑。
      

  2.   

    int width,height,newwidth,newheight;
    image=System.Drawing.Image.FromFile(fileName);
    width=image.Width;
    height=image.Height;
    if(width>height)
    {
    newwidth = thumb_maxsize;
    newheight=(int)((double)(image.Height)/(double)(image.Width) *(double)newwidth);
    }
    else
    {
    newheight = thumb_maxsize;
    newwidth = (int)((double)(image.Width)/(double)(image.Height) * newheight);
    }
    //
    //新建一个bmp图片
    bitmap = new System.Drawing.Bitmap(newwidth,newheight); //新建一个画板
    g = System.Drawing.Graphics.FromImage(bitmap);
    //设置高质量插值法
    g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
    //设置高质量,低速度呈现平滑程度
    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
    //清空一下画布
    g.Clear(System.Drawing.Color.White);
    //在指定位置画图
    g.DrawImage(image, new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), 
    new System.Drawing.Rectangle(0, 0, image.Width,image.Height),
    System.Drawing.GraphicsUnit.Pixel);
    //保存高清晰度的缩略图

    switch (strFileExt.ToLower()) 
    {
    case ".bmp":
    bitmap.Save(strCurrentPhotoPath + strFileName + strDefaultThumbnail +strFileExt,System.Drawing.Imaging.ImageFormat.Bmp);
    break;
    case ".gif":
    bitmap.Save(strCurrentPhotoPath + strFileName + strDefaultThumbnail +strFileExt,System.Drawing.Imaging.ImageFormat.Gif);
    break;
    case ".jpg":
    case ".jpeg":
    case ".jpe":
    bitmap.Save(strCurrentPhotoPath + strFileName + strDefaultThumbnail +strFileExt,System.Drawing.Imaging.ImageFormat.Jpeg);
    break;
    case ".wmf":
    bitmap.Save(strCurrentPhotoPath + strFileName + strDefaultThumbnail +".jpg",System.Drawing.Imaging.ImageFormat.Jpeg);
    break;
    case ".png":
    bitmap.Save(strCurrentPhotoPath + strFileName + strDefaultThumbnail +strFileExt,System.Drawing.Imaging.ImageFormat.Png);
    break;
    default:
    strFileExt=".jpg";
    bitmap.Save(strCurrentPhotoPath + strFileName + strDefaultThumbnail +strFileExt,System.Drawing.Imaging.ImageFormat.Jpeg);
    break;
    }
      

  3.   

    关键就是类似的这句话了:
    bitmap.Save("你的文件名称",System.Drawing.Imaging.ImageFormat.Jpeg);