文件名称:VS2010做的C#屏幕截图与本地图片合并实例
文件大小:42KB
文件格式:RAR
更新时间:2020-10-05 01:52:18
VS2010 屏幕截图
Microsoft Visual Studio 2010做的C#屏幕截图与本地图片合并实例,主要代码: Bitmap bitmapText = new Bitmap(iTextWidth, iTextHeight); Bitmap bitmapSource = (Bitmap)Bitmap.FromFile(sSource); //获取源图片的宽和高 int iSourceWidth = bitmapSource.Width; int iSourceHeight = bitmapSource.Height; //源图片需要压缩的比例 decimal decTimes = Math.Round((decimal)iTextHeight / (decimal)iSourceHeight, 4); decimal decNewSourceWidth = iSourceWidth * decTimes; decNewSourceWidth = Math.Round(decNewSourceWidth, 0); int iNewSourceWidth = Convert.ToInt32(decNewSourceWidth); //生成压缩后的bitmap Bitmap bitmapNewSource = f_scalebitmap(bitmapSource, decTimes); //两个bitmap拼合在一起 int iOutWidth = iNewSourceWidth + iTextWidth; int iOutHeight = iTextHeight; Bitmap bitmapOut = new Bitmap(iOutWidth, iOutHeight); Graphics graOut = Graphics.FromImage(bitmapOut); graOut.DrawImage(bitmapNewSource, 0, 0); graOut.CopyFromScreen(new Point(iBeginX, iBeginY), new Point(iNewSourceWidth, 0), bitmapText.Size);//截屏 bitmapOut.Save("D:\\temp\\output.bmp"); bitmapOut.Save("D:\\temp\\test1.png", System.Drawing.Imaging.ImageFormat.Png); graOut.Dispose(); bitmapOut.Dispose();
【文件预览】:
Demo_imageadd
----Demo_imageadd.suo(20KB)
----Demo_imageadd()
--------Program.cs(495B)
--------w_main.cs(5KB)
--------w_main.Designer.cs(3KB)
--------Properties()
--------obj()
--------w_main.resx(6KB)
--------Demo_imageadd.csproj(4KB)
--------bin()
----Demo_imageadd.sln(881B)