Results 1 to 10 of 10

Thread: Point Method [resolved]

  1. #1

    Thread Starter
    Lively Member UTGrim's Avatar
    Join Date
    Jan 2005
    Location
    Brazil
    Posts
    92

    Resolved Point Method [resolved]

    I need to know the value of a pixel in a picture, but the picture can't be visible.

    I tried the Point Method on an invisible PictureBox control. It returned -1, which according to MSDN Help means that the x and/or y coordinates were out of range.

    Does anybody know anything that could help me with this? Thanks!
    Last edited by UTGrim; Jan 24th, 2005 at 05:14 PM.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Point Method

    Look in the GAMING section of VBF. I think you want a BackBuffer.

  3. #3
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Point Method

    How do you load the picture. Is it on an OffscreenDC? Or in a picture ox that is not visible or what?

  4. #4

    Thread Starter
    Lively Member UTGrim's Avatar
    Join Date
    Jan 2005
    Location
    Brazil
    Posts
    92

    Re: Point Method

    Quote Originally Posted by NoteMe
    How do you load the picture. Is it on an OffscreenDC? Or in a picture ox that is not visible or what?
    I used the LoadPicture function on a PictureBox like this:

    VB Code:
    1. picGuide.Visible = False
    2. Set picGuide.Picture = LoadPicture(App.Path + "\guide.bmp")

    Sorry, I don't know what an OffscreenDC is, but I loaded then picture on an invisible PictureBox. I couldn't find anything similar to the Point Method on a picture object.

  5. #5
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Point Method

    I have never tried this in VB, and I don't have it installed. But you can try the GetPixel API. If that doesn't work, I think you have to load it to an offscreen DC, as I think dglienna ment.


    ØØ

  6. #6
    Lively Member StoneTheCrows's Avatar
    Join Date
    Dec 2004
    Location
    UK
    Posts
    71

    Re: Point Method

    I have a small App that does something similar to this where PictureBox.Visible is False. In it I just need to know whether each pixel is Zero or Greater than Zero.

    Code:
     
    Public Sub CheckPixels(ByVal Filename as String)
    	Picture1.Picture = LoadPicture(App.Path & Filename)
    	For x = 0 To Picture1.Width
    		For y = 0 To Picture1.Height
    			 If Picture1.Point(x, y) = 0 Then
    				 ' Do Something
    			 Else
    				 ' Do soemthing else
    			 End If
    		Next y
    	Next x
    	Picture1.Picture = Nothing
    End sub
    This seems to work just fine. Is there something I'm missing?
    StoneTheCrows

    _______________

    The future will be better tomorrow. (George W. Bush)

    (If you think my post was useful, please Rate it. Thanks)

  7. #7
    Lively Member StoneTheCrows's Avatar
    Join Date
    Dec 2004
    Location
    UK
    Posts
    71

    Re: Point Method

    OK, so I'm an idiot, my method worked fine because if the point method returns -1 then clearly it's not 0, which is all my code was looking for. So I tried the same thing but evaluating the actual value of each point in the picture box and sure enough it does return -1 in some cases. I think the reason is that the point has not been assigned a value as yet, probably because the loaded picture does not fill the picture box.

    I guess the solution to UTGrims problem is to trap for -1 and deal with it accordingly, either ignore it because it's not in the Image, or deal with it as a Black (0 Value) Pixel.
    StoneTheCrows

    _______________

    The future will be better tomorrow. (George W. Bush)

    (If you think my post was useful, please Rate it. Thanks)

  8. #8
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: Point Method

    An easy solution that you may be able to use is to have the Picture's Visible property set to True, but locate it off the edge of the form, or hide it behind another control.
    This world is not my home. I'm just passing through.

  9. #9
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Point Method

    In order for the Point method to work the point/pixel must be visible, ie visible to the user, unless the AutoRedraw property is set to True.

  10. #10

    Thread Starter
    Lively Member UTGrim's Avatar
    Join Date
    Jan 2005
    Location
    Brazil
    Posts
    92

    Re: Point Method

    Thank you, everybody that helped me! I tried the GetPixel API, but it wasn't what I wanted. What worked was brucevde's idea. 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