vb如何擦除一块图像并用trasparency替换 [英] vb how to wipe a piece of image and replace with trasparency

查看:196
本文介绍了vb如何擦除一块图像并用trasparency替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想擦拭一张图片并换上透明图片



我这样做了:



  Dim  aw  As   UInteger  = com.tilesizewidth 
Dim ah As UInteger = com.tilesizeheight
如果 multisel 那么
aw = Abs(pnt2.X - pnt.X)
ah = Abs(pnt2.X - pnt.X)
multisel = False
drawselrect = False
selectedfirstpnt = True
结束 如果

' Dim cloneimg = sourceimg.Clone()
使用 g As Graphics = Graphics.FromImage(sourceimg)
' g.DrawRectangle(New Pen(New TextureBrush(cloneimg)),pnt .X,pnt.Y,aw,啊)
g.FillRegion(Brushes.Trasparent,区域(矩形(pnt.X,pnt.Y,aw,啊)))
' g.FillRegion(Brushes.White,New Region(新矩形(pnt.X,pnt.Y,aw,啊)))
结束 使用

imgsaved = 错误
pic .Invalidate()





g.FillRegion(Brushes.Trasparent,New Region(New Rectangle(pnt.X,pnt.Y,aw)啊)))不工作



g.FillRegion(Brushes.White,New Region(新矩形(pnt.X,pnt.Y,aw,啊)))有效,但它是白色的!

解决方案

现在这是我难看的解决方案!



  Dim  aw 作为  UInteger  = com.tilesizewidth + pnt.X 
Dim ah As UInteger = com.tilesizeheight + pnt.Y
如果 multisel 那么
aw = pnt2.X
ah = pnt2 .Y
multisel = 错误
drawselrect = 错误
selectedfirstpnt = True
结束 如果

Dim edit = 位图(sourceimg)
对于 i 作为 整数 = pnt.X aw
对于 j 作为 < span class =code-keyword> Integer = pnt.Y To ah
edit.SetPixel(i,j,Color.Transparent)
下一步
下一步

sourceimg = edit


I want to wipe a piece of image and replace it with trasparency

I did this:

Dim aw As UInteger = com.tilesizewidth
        Dim ah As UInteger = com.tilesizeheight
        If multisel Then
            aw = Abs(pnt2.X - pnt.X)
            ah = Abs(pnt2.X - pnt.X)
            multisel = False
            drawselrect = False
            selectedfirstpnt = True
        End If

        'Dim cloneimg = sourceimg.Clone()
        Using g As Graphics = Graphics.FromImage(sourceimg)
            'g.DrawRectangle(New Pen(New TextureBrush(cloneimg)), pnt.X, pnt.Y, aw, ah)
            g.FillRegion(Brushes.Trasparent, New Region(New Rectangle(pnt.X, pnt.Y, aw, ah)))
            'g.FillRegion(Brushes.White, New Region(New Rectangle(pnt.X, pnt.Y, aw, ah)))
        End Using

        imgsaved = False
        pic.Invalidate()



g.FillRegion(Brushes.Trasparent, New Region(New Rectangle(pnt.X, pnt.Y, aw, ah))) don't work

g.FillRegion(Brushes.White, New Region(New Rectangle(pnt.X, pnt.Y, aw, ah))) works but it's white!!

解决方案

this is my ugly solution for now!

Dim aw As UInteger = com.tilesizewidth + pnt.X
        Dim ah As UInteger = com.tilesizeheight + pnt.Y
        If multisel Then
            aw = pnt2.X
            ah = pnt2.Y
            multisel = False
            drawselrect = False
            selectedfirstpnt = True
        End If

        Dim edit = New Bitmap(sourceimg)
        For i As Integer = pnt.X To aw
            For j As Integer = pnt.Y To ah
                edit.SetPixel(i, j, Color.Transparent)
            Next
        Next

        sourceimg = edit


这篇关于vb如何擦除一块图像并用trasparency替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆