Results 1 to 14 of 14

Thread: delete region and make...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    77

    Question delete region and make...

    How can I delete a region???
    Last edited by dddsss; Aug 2nd, 2007 at 09:23 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: delete region

    Whats a region?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    77

    Re: delete region

    region for TransparentColor(mask color)
    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
    this code make a mask color in picture box.
    I want to delete a region

  4. #4
    New Member
    Join Date
    Jul 2007
    Posts
    10

    Re: delete region

    Quote Originally Posted by dddsss
    How can I delete a region???
    Do you mean the regions that are used in the Windows GDI (Graphical Device Interface)??

  5. #5
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: delete region

    without testing I'm pretty sure a simple...
    Code:
    SetWindowRgn picmainskin.hwnd, 0, True
    will do.

  6. #6
    New Member
    Join Date
    Jul 2007
    Posts
    10

    Re: delete 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.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    77

    Re: delete region

    thanks,
    SetWindowRgn picmainskin.hwnd, 0, True
    its worker

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: delete region

    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.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    77

    Re: delete region

    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"

  10. #10
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: delete region

    Quote Originally Posted by dddsss
    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.

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: delete region

    Quote Originally Posted by dddsss
    How can I delete a region???
    Quote Originally Posted by dddsss
    sory,but delete region is not the problem.
    What, exactly, is the problem?

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    77

    Re: delete region and make...

    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
    Attached Files Attached Files
    Last edited by dddsss; Aug 2nd, 2007 at 11:54 AM.

  13. #13
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: delete region and make...

    This code by La Volpe has a few region functions including one for creating a region by mask colour. It's good code.

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    77

    Re: delete region and make...

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width