|
-
Feb 19th, 2002, 06:58 AM
#1
Thread Starter
Fanatic Member
GetPixel returns -1. how to fix?
Hi,
In some times the GetPixel returns me a (-1) value.
Why? And How can I fix it?
Thank you,
Arie.
-
Feb 19th, 2002, 07:37 AM
#2
Frenzied Member
is it possible that you used it out of the image bounds? GetPixel uses pixels for coordinates not the vb twips so if you set your picturebox or whatever you use to twips and use them to get the position that might be the reason for the -1.
Sanity is a full time job
Puh das war harter Stoff!
-
Feb 20th, 2002, 11:14 AM
#3
Thread Starter
Fanatic Member
In my picturebox I use from (0,0) to (320,320).
is it right? because it works on the most of the times.
I don't know why it gives me (-1).
Thank you,
Arie.
-
Feb 20th, 2002, 11:45 AM
#4
Frenzied Member
well I don't know, but the most probable reason for getting a -1 would be beeing out of bounds remember if you pic is 320 pixels wide the range is from 0 to 319 not 320, but it might be something else I don't know about.
Sanity is a full time job
Puh das war harter Stoff!
-
Feb 21st, 2002, 02:16 PM
#5
Thread Starter
Fanatic Member
Does anyone knows another reason for the GetPixel problem?
Thank you for posting,
Arie.
-
Feb 21st, 2002, 04:32 PM
#6
Good Ol' Platypus
Try messing around with AutoRedraw settings.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Feb 22nd, 2002, 02:55 PM
#7
Thread Starter
Fanatic Member
My picture's autoredraw is set to false and if it wasn't my game won't work! anyone with other options??
please help!
thank you,
Arie.
-
Feb 22nd, 2002, 06:21 PM
#8
I think -1 is the default window color, if your Picturebox's BackColor is set to vbButtonFace you'll get that color.
Just set the Picturebox's BackColor to something else (You can for example use the GetSysColor API to get the actual color of vbButtonFace)
-
Feb 23rd, 2002, 05:48 AM
#9
Thread Starter
Fanatic Member
but,
when I do the GetPixel function I do it for the picMain.hdc.
not to Form1.hdc.
any other ideas?
thank you anyway,
Arie.
-
Feb 23rd, 2002, 12:41 PM
#10
no, -1 always means error. And this is usually due to coordinates that don't exist (out of bounds).
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 24th, 2002, 12:22 PM
#11
Thread Starter
Fanatic Member
Ok, but my GetPixel is IN_BOUNDS!!!!
That's why I'm asking what else could it be?
It not happens all the time, it's pretty rare...
Most of the times it works fine...
But when it happens it ruins my game!
What can it be? please help!
Thank you so far,
Arie.
-
Feb 24th, 2002, 01:20 PM
#12
Good Ol' Platypus
Well about the autoredraw thing maybe this is part of a bigger thing... why does your surface need to be False?
Other than that, just loop until your answer is not -1.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Feb 25th, 2002, 09:59 AM
#13
Hyperactive Member
maybe it has to do with the color settings or the setting it was saved in? ie 8 or maybe 15 bit?
-
Feb 25th, 2002, 11:14 AM
#14
Frenzied Member
well I guess it would help if you would post some code...
Sanity is a full time job
Puh das war harter Stoff!
-
Feb 26th, 2002, 03:03 PM
#15
Addicted Member
If your picturebox is not autoredraw, if a window is covering it, the GetPixel call will most likely fail because the pixel at that location has been erased by the window now covering it.
Set your picturebox's autoredraw to true, and then once you draw to it, call .Refresh and VB will copy the changes to the screen for you. This prevents both flicker, and other windows from erasing your image.
"1 4m 4 1337 #4xz0r!'
Janus
-
Mar 1st, 2002, 11:40 AM
#16
Frenzied Member
-
Mar 1st, 2002, 11:42 AM
#17
Frenzied Member
already said that
seems not to help either
maybe you should just buy a new pc
Sanity is a full time job
Puh das war harter Stoff!
-
Mar 1st, 2002, 11:45 AM
#18
-
Mar 1st, 2002, 07:57 PM
#19
Frenzied Member
true true
well why don't you paste any code. I am sure you will get help then!
Sanity is a full time job
Puh das war harter Stoff!
-
Mar 3rd, 2002, 12:13 PM
#20
Frenzied Member
Maybe he doesn't want us to steal it
-
Mar 3rd, 2002, 01:17 PM
#21
Frenzied Member
Yeah I collect all kinds of buggy code...
well yeah maybe we could kill the bugs, if he'd post it...
that would make it worth stealing though....
Sanity is a full time job
Puh das war harter Stoff!
-
Mar 3rd, 2002, 05:34 PM
#22
Frenzied Member
Yeah, but if the code doesn't work it's worthless 
Look Arie, we won't be able to help unless you post the code...
-
Mar 3rd, 2002, 06:25 PM
#23
Good Ol' Platypus
He posted his code in a different thread.
The 3rd reply is the code:
http://www.vbforums.com/showthread.p...hreadid=148181
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Mar 5th, 2002, 01:16 PM
#24
Lively Member
THAT SNEAK! He obviously didn't trust us...
We aren't good enough for his needs... *Sniff*
Excuse me....
MWAAAAAAAAAHAAAAAA! burble burble
Sigh. I'm ok, the counseling has worked, all I had to do was hit a chair with a rubber baseball bat
Ich widerstehe allem - nur nicht der Versuchung
(I can resist anything but temptation)
-
Mar 5th, 2002, 02:04 PM
#25
Thread Starter
Fanatic Member
Thanx!!!
It's OK!!!
I have answered me oh right!!!
Thank you very much!!!
Arie.
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
|