|
-
Jan 23rd, 2005, 11:00 PM
#1
Thread Starter
Lively Member
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.
-
Jan 23rd, 2005, 11:02 PM
#2
Re: Point Method
Look in the GAMING section of VBF. I think you want a BackBuffer.
-
Jan 23rd, 2005, 11:04 PM
#3
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?
-
Jan 23rd, 2005, 11:15 PM
#4
Thread Starter
Lively Member
Re: Point Method
 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:
picGuide.Visible = False
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.
-
Jan 23rd, 2005, 11:18 PM
#5
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.
ØØ
-
Jan 24th, 2005, 03:50 AM
#6
Lively Member
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)
-
Jan 24th, 2005, 04:33 AM
#7
Lively Member
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)
-
Jan 24th, 2005, 05:10 AM
#8
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.
-
Jan 24th, 2005, 11:32 AM
#9
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.
-
Jan 24th, 2005, 05:13 PM
#10
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|