从剪贴板取出图片然后写上字保存到文件

时光总嘲笑我的痴心妄想 提交于 2020-03-03 14:51:58
Image bmap;
IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();
bmap = (Image)(data.GetData(typeof(System.Drawing.Bitmap)));
Graphics g = Graphics.FromImage(bmap);

SolidBrush drawBrush = new SolidBrush(Color.Red);
Font drawFont = new Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Millimeter);
int xPos = bmap.Height - ( bmap.Height-25 );
int yPos = 3;

g.DrawString ("zydzydyzydydydyyydydy", drawFont, drawBrush, xPos, yPos);

string sPicPath = "d:\\filename.jpg";
string sPreFix = "d:\\xxx";

Image smBmap ;

smBmap = bmap.GetThumbnailImage(bmap.Width, bmap.Height, null, System.IntPtr.Zero);

smBmap.Save(sPicPath, System.Drawing.Imaging.ImageFormat.Jpeg);

bmap.Save(sPreFix + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
bmap = null;
smBmap = null; 
 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!