关于vb.net矢量图的信息
矢量图上那些大小不变的图标VB.NET怎样能实现
矢量图是指大小变化,但是不出现锯齿状的失真,通常是用其他图形设计软件,比如coreldraw输出图片,拿出来使用,直接用vbnet不能实现吧
成都创新互联主要从事成都网站制作、网站建设、外贸网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务塔城,10年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575
VB.NET中如何运用如下图的这种矢量图形?
你的方法是常用的方法了,除非你自己写GDI类或者用第三方控件了
怎样用VB把一张图片透明的放到Picture里,在线等
Public Function TranBlt(DestHdc As Long, X As Long, Y As Long, W As Long, H As Long, srcHdcOrBmp As Long, Optional srcX As Integer, Optional srcY As Integer, Optional srcW As Long, Optional srcH As Long, Optional tc As Long = -1, Optional IsBmp As Boolean) As Long
'srcHdcOrBmp参数 传入的可以是hdc也可以是Bmp对象的Handle,
'IsBmp参数 为真时srcHdcOrBmp代表Bmp对象的Handle,为假时代表hdc
'返回值 成功时返回透明色,不成功时返回-1
Dim tHdc(3) As MemHdc
Dim J As Long, oc As Long, I As Long, Bm As BITMAP, cc As Long, NewDc As Long
Dim sw As Long, sh As Long, sBmp As Long, sHdc As Long, obm As Long, NewX As Long, NewY As Long
If DestHdc = 0 Or srcHdcOrBmp = 0 Or W = 1 And H = 1 Then GoTo fail
If IsBmp Then '若传入的是Bmp句柄,需为其创建一个临时DC
sBmp = srcHdcOrBmp
tHdc(3) = NewMyHdc(DestHdc, 0, 0, srcHdcOrBmp)
sHdc = tHdc(3).hdc
Else
sHdc = srcHdcOrBmp
If srcW = 0 Then sBmp = GetCurrentObject(sHdc, 7)
End If
If sHdc = 0 Or sBmp = 0 Then GoTo fail
If srcW = 0 Then '若没有提供源图大小,需取得整个源图大小
GetObj sBmp, Len(Bm), Bm
sw = Bm.bmWidth - srcX
sh = Bm.bmHeight - srcY
Else
sw = srcW
sh = srcH
End If
If sw 1 Or sh 1 Then GoTo fail
If tc = -1 Then
cc = GetPixel(sHdc, srcX, srcY) '将左上角第一个像素作为源图背景色,用于透明
Else
cc = tc
End If
If W sw Or H sh Then
tHdc(2) = NewMyHdc(DestHdc, W, H)
StretchBlt tHdc(2).hdc, 0, 0, W, H, sHdc, srcX, srcY, sw, sh, vbSrcCopy
'先将源图缩放,下面步骤就一样了。
NewDc = tHdc(2).hdc
Else
NewDc = sHdc
NewX = srcX
NewY = srcY
End If
BitBlt DestHdc, X, Y, W, H, NewDc, NewX, NewY, vbSrcInvert
'将源图先反色(XOR)绘入目标图,若源图背景为黑色,此步可省
'下面是制作Mask图的方法
I = CreateBitmap(W, H, 1, 1, ByVal 0) '建立单色位图
tHdc(0) = NewMyHdc(DestHdc, 0, 0, I) '为单色图建立新DC,并选入
tHdc(1) = NewMyHdc(DestHdc, W, H) '另建一个彩色图及DC,用于存放Mask图
oc = SetBkColor(NewDc, cc) '将源图背景色改为透明色
BitBlt tHdc(0).hdc, 0, 0, W, H, NewDc, NewX, NewY, vbSrcCopy
'先将源图绘入单色DC,由此产生只有正反的Mask图,背景色(透明色)为黑,其它为白
SetBkColor NewDc, oc '恢复源图背景色,不是必须的,但这是个好习惯。
BitBlt tHdc(1).hdc, 0, 0, W, H, tHdc(0).hdc, 0, 0, vbSrcCopy
'单色DC必须复制进彩色DC才能进行后面的的AND运算
'Mask图完成,并已放入彩色DC
BitBlt DestHdc, X, Y, W, H, tHdc(1).hdc, 0, 0, vbSrcAnd '标准透明绘图:选将Mask图用And运算绘入,
BitBlt DestHdc, X, Y, W, H, NewDc, NewX, NewY, vbSrcInvert '再将源图以反色(XOR)绘入一次
DelMyHdc tHdc(0)
DelMyHdc tHdc(1)
If tHdc(2).hdc 0 Then DelMyHdc tHdc(2)
If tHdc(3).hdc 0 Then DelMyHdc tHdc(3)
TranBlt = cc
Exit Function
fail:
If tHdc(3).hdc 0 Then DelMyHdc tHdc(3)
TranBlt = -1
End Function
Private Function NewMyHdc(dHdc As Long, W As Long, H As Long, Optional Bm As Long) As MemHdc
With NewMyHdc
.hdc = CreateCompatibleDC(dHdc)
If Bm = 0 Then
.Bmp = CreateCompatibleBitmap(dHdc, W, H)
Else
.Bmp = Bm
End If
.obm = SelectObject(.hdc, .Bmp)
End With
End Function
Private Function DelMyHdc(MyHdc As MemHdc, Optional nobmp As Boolean) As MemHdc
With MyHdc
If .hdc 0 And .obm 0 Then SelectObject .hdc, .obm
If nobmp = False And .Bmp 0 Then DeleteObject .Bmp
If .hdc 0 Then DeleteDC .hdc
End With
End Function
把这个函数放在一个BAS里,然后在窗体里
TranBlt pic.hdc, X,Y,W,H,PIC2.Picture.Handle, _
TX,TY,TW,TH, , True
就OK
本文名称:关于vb.net矢量图的信息
当前地址:http://hbruida.cn/article/dscsjgi.html