vb.net图片加水印 net 图片加水印

图片怎么加水印第一步,下载“U速水印工厂”软件并安装 。选择左侧的【图像水印】功能按钮 , 然后点击【添加文件】按钮,将需要水印的图像导入软件,软件支持批处理 。请一次全部添加 。第二步,设置水印,首先选择水印类型(文字水印或图片水?。?单个或多个);然后设置水印文本内容或者上传logo;最后设置水印样式:大小/颜色/字体/透明度/缩放/旋转角度/水印密度(数量)/位置/边距等 。以上实时预览 , 点击放大预览 。第三步 , 如下图所示 , 设置好输出目录(文件保存在哪个文件夹)后,点击【开始转换】按钮,启动软件程序 。所有图片加水印后,软件会自动打开输出目录文件夹 。第四步,从案例中可以看出 , 所有图片都添加了统一的水印 。
VB 给图片添加文字水印VB6.0给已有图片添加文字可通过定位的Print 方法实现 。要将添加文字的位图储存为JPG格式文件 , 需要使用API函数等实现 。
具体步骤:
1)在图片框加载需要添加文字水印的图片 。
2)使用如下代码实现添加文字到图片框 。
Private Sub CmdEdit_Click() '修改
Dim strTxt As String
strTxt = "风雨无阻 拍摄"
Picture1.FontSize = 18
Picture1.CurrentY = Picture1.ScaleHeight - 30
Picture1.CurrentX = Picture1.ScaleWidth / 2 - Picture1.TextWidth(strTxt) / 2
Picture1.ForeColor = vbWhite
Picture1.FontItalic = True
Picture1.Print strTxt
End Sub
3)将以下API转换图片格式代码放置于标准模块,模块命名为saveApg 。
Option Explicit
Public Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
Public Type GdiplusStartupInput
GdiplusVersion As Long
DebugEventCallback As Long
SuppressBackgroundThread As Long
SuppressExternalCodecs As Long
End Type
Public Type EncoderParameter
GUID As GUID
NumberOfValues As Long
type As Long
Value As Long
End Type
Public Type EncoderParameters
Count As Long
Parameter As EncoderParameter
End Type
Public Declare Function GdiplusStartup Lib "GDIPlus" (token As Long, inputbuf As GdiplusStartupInput, ByVal outputbuf As Long) As Long
Public Declare Function GdiplusShutdown Lib "GDIPlus" (ByVal token As Long) As Long
Public Declare Function GdipCreateBitmapFromHBITMAP Lib "GDIPlus" (ByVal hbm As Long, ByVal hpal As Long, Bitmap As Long) As Long
Public Declare Function GdipDisposeImage Lib "GDIPlus" (ByVal Image As Long) As Long
Public Declare Function GdipSaveImageToFile Lib "GDIPlus" (ByVal Image As Long, ByVal fileName As Long, clsidEncoder As GUID, encoderParams As Any) As Long
Public Declare Function CLSIDFromString Lib "ole32" (ByVal str As Long, id As GUID) As Long
Public Declare Function GdipCreateBitmapFromFile Lib "GDIPlus" (ByVal fileName As Long, Bitmap As Long) As Long
Public Function PictureBoxSaveJPG(ByVal pict As StdPicture, ByVal fileName As String, Optional ByVal quality As Byte = 80) As Boolean
Dim tSI As GdiplusStartupInput
Dim lRes As Long
Dim lGDIP As Long
Dim lBitmap As Long
'初始化 GDI+
tSI.GdiplusVersion = 1
lRes = GdiplusStartup(lGDIP, tSI, 0)
If lRes = 0 Then
'从句柄创建 GDI+ 图像
lRes = GdipCreateBitmapFromHBITMAP(pict.Handle, 0, lBitmap)
If lRes = 0 Then
Dim tJpgEncoder As GUID
Dim tParams As EncoderParameters
'初始化解码器的GUID标识
CLSIDFromString StrPtr("{557CF401-1A04-11D3-9A73-0000F81EF32E}"), tJpgEncoder
'设置解码器参数
tParams.Count = 1
With tParams.Parameter ' Quality
'得到Quality参数的GUID标识
【vb.net图片加水印 net 图片加水印】

推荐阅读