資源簡介
C#圖片加文字水印和圖片水印源碼,稍加改動即可使用,附demo

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Drawing.Imaging;
using?System.Text;
using?System.Windows.Forms;
using?ThoughtWorks.QRCode.Codec;
namespace?ImgDemo
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????????Init();
????????}
????????void?Init()
????????{
????????????string?text?=?“QQ:358020965“;
????????????Image?img?=?global::ImgDemo.Properties.Resources.bg;
????????????int?PhotoWidth?=?img.Width;
????????????int?PhotoHeight?=?img.Height;
????????????Bitmap?bitPhoto?=?new?Bitmap(PhotoWidth?PhotoHeight?PixelFormat.Format24bppRgb);
????????????bitPhoto.SetResolution(img.HorizontalResolution?img.VerticalResolution);
????????????img?=?PreviewImg.CreateTextToImg(bitPhoto?img?PhotoWidth?PhotoHeight?12?text?0?PhotoWidth?-?120);
????????????Image?QRimg?=?GetQRImage(text);
????????????img?=?PreviewImg.CreateImgToImg(QRimg?img?PhotoWidth?PhotoHeight?80?80?80?80);
????????????this.pictureBox1.Image?=?img;
????????}
????????Image?GetQRImage(string?scode)
????????{
????????????QRCodeEncoder?qrCodeEncoder?=?new?QRCodeEncoder();
????????????System.IO.MemoryStream?ms?=?new?System.IO.MemoryStream();
????????????qrCodeEncoder.QRCodeBackgroundColor?=?Color.White;
????????????qrCodeEncoder.QRCodeForegroundColor?=?Color.Black;
????????????qrCodeEncoder.QRCodeVersion?=?0;
????????????qrCodeEncoder.QRCodeErrorCorrect?=?QRCodeEncoder.ERROR_CORRECTION.L;
????????????System.Drawing.Image?myimg?=?qrCodeEncoder.Encode(scode?System.Text.Encoding.UTF8);
????????????return?myimg;
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-05-05?16:20??ImgDemo\
?????文件???????18196??2016-05-05?16:07??ImgDemo\bg.png
?????目錄???????????0??2016-05-05?16:05??ImgDemo\bin\
?????目錄???????????0??2016-05-05?16:19??ImgDemo\bin\Debug\
?????文件???????33792??2016-05-05?16:20??ImgDemo\bin\Debug\ImgDemo.exe
?????文件???????24064??2016-05-05?16:20??ImgDemo\bin\Debug\ImgDemo.pdb
?????文件???????21680??2016-05-05?16:21??ImgDemo\bin\Debug\ImgDemo.vshost.exe
?????文件?????????490??2015-07-10?19:01??ImgDemo\bin\Debug\ImgDemo.vshost.exe.manifest
?????文件?????6209536??2016-04-26?17:25??ImgDemo\bin\Debug\ThoughtWorks.QRCode.dll
?????文件????????1729??2016-05-05?16:20??ImgDemo\Form1.cs
?????文件????????2280??2016-05-05?16:15??ImgDemo\Form1.Designer.cs
?????文件????????5817??2016-05-05?16:15??ImgDemo\Form1.resx
?????文件????????3805??2016-05-05?16:19??ImgDemo\ImgDemo.csproj
?????文件?????????228??2016-05-05?16:15??ImgDemo\ImgDemo.csproj.user
?????目錄???????????0??2016-05-05?16:05??ImgDemo\obj\
?????目錄???????????0??2016-05-05?16:05??ImgDemo\obj\Debug\
?????文件?????????790??2016-05-05?16:05??ImgDemo\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件????????6197??2016-05-05?16:18??ImgDemo\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件?????????653??2016-05-05?16:21??ImgDemo\obj\Debug\ImgDemo.csproj.FileListAbsolute.txt
?????文件?????????873??2016-05-05?16:16??ImgDemo\obj\Debug\ImgDemo.csproj.GenerateResource.Cache
?????文件???????33792??2016-05-05?16:20??ImgDemo\obj\Debug\ImgDemo.exe
?????文件?????????180??2016-05-05?16:19??ImgDemo\obj\Debug\ImgDemo.Form1.resources
?????文件???????24064??2016-05-05?16:20??ImgDemo\obj\Debug\ImgDemo.pdb
?????文件???????23351??2016-05-05?16:19??ImgDemo\obj\Debug\ImgDemo.Properties.Resources.resources
?????目錄???????????0??2016-05-05?16:05??ImgDemo\obj\Debug\TempPE\
?????文件????????3584??2016-05-05?16:10??ImgDemo\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
?????文件????????5716??2016-05-05?16:11??ImgDemo\PreviewImg.cs
?????文件?????????468??2016-05-05?16:05??ImgDemo\Program.cs
?????目錄???????????0??2016-05-05?16:10??ImgDemo\Properties\
?????文件????????1322??2016-05-05?16:05??ImgDemo\Properties\AssemblyInfo.cs
?????文件????????3216??2016-05-05?16:10??ImgDemo\Properties\Resources.Designer.cs
............此處省略3個文件信息
評論
共有 條評論