How can I delete a region???
Printable View
How can I delete a region???
Whats a region?
region for TransparentColor(mask color)
this code make a mask color in picture box.Code: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
I want to delete a region
Do you mean the regions that are used in the Windows GDI (Graphical Device Interface)??Quote:
Originally Posted by dddsss
without testing I'm pretty sure a simple...will do.Code:SetWindowRgn picmainskin.hwnd, 0, True
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.
thanks,
SetWindowRgn picmainskin.hwnd, 0, True
its worker
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.
Thank you. :)
sory,but delete region is not the problem. if I try to make a mask color in the picture box there is pictures that "be cut"
could you try writing that again, I'm struggling to understand what you mean.Quote:
Originally Posted by dddsss
Quote:
Originally Posted by dddsss
What, exactly, is the problem?Quote:
Originally Posted by dddsss
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
This code by La Volpe has a few region functions including one for creating a region by mask colour. It's good code.
thanks