如何实现存储一个编辑好的图像,下次需要再提取出来,进行修改? 那你用Bitmap.Save或Image.Save不就行了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 能说的再详细点吗?现在我在一个panel上画了一些控件,并编辑了相应事件,我要完成把这些东西存储,下次再调出继续编辑。 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; } 关键就是类似的这句话了:bitmap.Save("你的文件名称",System.Drawing.Imaging.ImageFormat.Jpeg); 多线程问题(文字版) winform程序 多个线程运行,当挂起一个线程,其它也停止运行,为什么呢? 怎么提高if 语句的速度 dataGridView更新数据 C#windows窗体编程问题 关于DataAdapter的问题,有些迷惑,求助~ asp.net 中 关于货币的显示格式 为什么C#读EXCEL的时候,只能读出字符串,数字却读不出来? 数据导入导出的问题 在线求救!急急急急急!!!!! ???我这个对access的操作错在哪里? 请问如何在自定义控件中加入ToolTip属性?分不够可以再加!
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;
}
bitmap.Save("你的文件名称",System.Drawing.Imaging.ImageFormat.Jpeg);