Private Function MakeRegion(picSkin As PictureBox) As Long
Dim x As Long, y As Long, StartLineX As Long
Dim FullRegion As Long, LineRegion As Long
Dim TransparentColor As Long
Dim InFirstRegion As Boolean
Dim InLine As Boolean
Dim hdc As Long
Dim PicWidth As Long
Dim PicHeight As Long
hdc = picSkin.hdc
PicWidth = picSkin.ScaleWidth
PicHeight = picSkin.ScaleHeight
InFirstRegion = True: InLine = False
x = y = StartLineX = 0
TransparentColor = 14215660
For y = 0 To PicHeight - 1
For x = 0 To PicWidth - 1
If GetPixel(hdc, x, y) = TransparentColor Or x = PicWidth Then
If InLine Then
InLine = False
LineRegion = CreateRectRgn(StartLineX, y, x, y + 1)
If InFirstRegion Then
FullRegion = LineRegion
InFirstRegion = False
Else
CombineRgn FullRegion, FullRegion, LineRegion, RGN_OR
DeleteObject LineRegion
End If
End If
Else
If Not InLine Then
InLine = True
StartLineX = x
End If
End If
Next
Next
MakeRegion = FullRegion
End Function
Private Sub setrgn(picmainskin As PictureBox)
Dim WindowRegion As Long
WindowRegion = MakeRegion(picmainskin)
SetWindowRgn picmainskin.hwnd, WindowRegion, True
End Sub
this code make a mask color in picture box.
I want to delete a region
You may use the CombineRgn function with with the appropriate combine mode like RGN_DIFF to delete a part of a region, or delete an entire region altogether.
If you consider this resolved, you could help us out by pulling down the Thread Tools menu and clicking the Mark Thread Resolved menu item. That will let everyone know that you have your answer.
delete region is not help for me,the problem is in make region,there are some images that if i create region,parts of the image are removed.
for example take this file