getcolor readpixel readpixelfastBlitzPlus Forums/BlitzPlus Programming/getcolor readpixel readpixelfast
| Could someone please explain the differences and advantages between these commands? |
Also is there an accurate way to get color from both a 32bit and 16bit display? I have no problem in 32 bit using readpixel but if I am in 16bit I get garbage data. Since I can't set the users windows settings this limits me to fullscreen or my colour selection won't work.
Thanks in advance
| I will be happy to assist you if you change your alias. |
| Yeah I was thinking it's pretty bad, as a lot of people's lives are affected by it ... unless of course you have it too.|
Anyway as a start, try just reading the help on those commands in the IDE as that's quite informative.
| Wow can you guys jump to conclusions. I was born on June 28th. I am a boy. My sign+gender=mynick. If I called myself Geminiboy would you demand I change that as well? |
Instead of being offended by everything you see why don't you spend a second and ask me about the nick first?
I have read the help in the commands but they do not directly compare the three commands. I can make the assumption that getcolor is the slowest. Does one of the three commands work in both 16bit and 32bit modes or is there a reliable way to make one of them work?
| OT: Regardless of your explanation I agree with sswift and Grey Alien. 'Cancer' is a vile word in any context.|
Instead of being offended by everything you see why don't you spend a second and ask me about the nick first?You're getting off to a really bad start with that attitude.
| GfK: Cancer is and was an astrological sign long before it was used to describe the medical condition. How is an astroligical sign vile? Don't let one definition you dislike define the others.|
Why am I getting off to a bad start by asking someone to take the time and ask me about my alias before jumping to incorrect conclusions? I asked a fair programming question and I was ridiculed about my alias instead. I didn't ask for this debate... I wanted to know more about colour selection.
I didn't ridicule you about your alias. I simply asked you to change it. My mother died from cancer a few years ago as many Blitzers here know. Of course lots of people die, but this was a prolonged death over the course of a year and was very traumatic for me. I'm already reminded of it all the time by commercials and TV news. I don't want to also be reminded of it every time I come to the Blitz forums as well.
So it doesn't matter to me why you chose the alias. I'm not passing judgement on you for that. I don't expect people to stop making jokes about diseases, I do it myself. I just don't want to see the word every time I come here and be reminded of it. That's all.
Anyway, I can't force you to change your alias. I'm just asking you to. If you want assistance from me, then you should have the common courtesy to do me that small favor. It's not a big deal to change your alias.
| I am sorry to hear about the loss of your mother. I have lost an aunt and uncle as well as many close family friends to cancer. My mother and grandmother have both survived cancer (remission). I give donations every year to cancer research and it is something that I take very seriously.|
While I respect your request I am not going to change my alias. My alias is based on my astrological sign and not the other cancer. I have been using this alias without problem for over 10 years and it is my online persona. It is not intended to offend anyone. If that means that I will not receive your help then I am sorry to hear that.
| You've listed the commands pretty much in speed order. GetColor is "safe" in that it won't crash if you ask it to read off screen, but this slows it down. ReadPixel will crash if reading off screen, but is a bit faster, especially if you call LockBuffer(BackBuffer()) first, and UnlockBuffer afterwards (assuming that you are reading loads in a loop). However, I never used either of those in my games, I used ReadPixelFast. You *must* lock the buffer for this to work and unlock it when you are finish. Plus you'll get Memory Access violations if you try to read outside of the screen. Also complement the use of this with WritePixelFast. You can do some pretty interesting stuff with these commands BUT they still aren't fast enough to do large areas of complex stuff like alpha blending in real-time. |
| Have a look into lockedpixels, lockedformat and lockedpitch for really fast pixel operations.. |
| I did a load of tests with lockedpixels and didn't find it faster than using ReadPixelFast and WritePixelFast (on my machine at least). |
| Thanks guys! Right now I am using ReadPixel and it works at a fast enough speed for me (I locked the framerate to 60fps) but I can't get ReadPixel to work in 16bit. If I do fullscreen 32 bit or windowed and I have my desktop set to 32 bit then everything works fine. If I try 16bit I can't read any colours.|
I am making a Risk type game and I am using colour selection to determine if I am over a country or not. Right now I have no need for anything but reading in colour. I am not using WritePixel or WritePixelFast. I should probably send a test version around to make sure ReadPixel is fast enough on other people's machines.
| Hmm... what graphics are you using? is it possible that in 16 bit mode the gfx becomes kinda "dithered"? (just a thought (long-shot)) |
| I am using pngs. My color map is one image... a 1024x1024 32bit png. I am not sure if the image dithers when it is in 16bit mode. None of the colors read in 16bit mode. |
| Grey - don't want to hijack this thread but I've found that on my machine using lockedpixels and poking directly to the buffer I can push around 200,000 pixels per frame at frame rates above 40fps while if I use writepixelfast I can barely manage 30,000 to 40,000 pixels per frame before the frame rate drops to around 15-20 fps. |
| fair enough, my test must have be flawed, it was a while ago now. Actually I think it was Reading not writing and the delay was just caused by the video buffer to RAM pipeline. |
| So what sort of speed increase should I expect if I switched from ReadPixel to ReadPixelFast? In your opinion is it worth it? I am getting great freamerates now but I am not done a lot of the game code. I am thinking it would be easier to switch now than later. |
| Okay I switched to ReadPixelFast and there seems to be no noticable change. I guess I don't understand why there would be a ReadPixel and ReadPixelFast. If RPF is always faster then why have two commands? Is locking and unlocking the buffer the potential problem?|
I also came up with a solution for my 32bit and 16bit problem. I can now select my countries in either mode just fine.
| Readpixel has error checking - ie you can be a little more careless with your arguments, readpixelfast has to be performed on a locked buffer and within the boundaries of the current locked buffer. Obviously just because readpixel doesn't care as much about invalid coordinates you should still always use valid coordinates..|
I don't think there is too much difference in speed between readpixelfast and readpixel. If you are simply getting the color at a small number of points per frame (on my 500 Mhz machine less than a few thousand) then there's really no difference between the two.
| Thanks Matty. That makes sense now. I have ReadPixelFast working now so I will stick with it.|
Thanks everyone for their help.
| hi guys,|
i have a related question : i actually am processing almost 1000 images taken from a CTSCAN let's say of a human leg, and i wish to extract the brightest pixels from each picture, in other words the bones; i plan to build meshes out of these pixels, then render them and provide a real-time interactive view of, for instance, the bone fracture encountered.
until now i use getcolor, RP and RPF but the process remains slohohohohowww
could i adress directly the allocated memory where each image is loaded?
thank you in advance for any help!
| Re: the nickname|
If it matters, the astrological version didn't even come into my head, the disease version did.
'CancerianBoy' would ne a nice compromise, and I think people will pick up on that right away :)
| It gets to be a bit wordy and a lot more to type in :). I will make you a deal... I promise to never complain about anyone elses nickname and I'll keep mine the way it is :) |
| If it matters, being cancerian also, astrology was the first thing that came to mind when I seen your alias. |
But then I may be predisposed to arrive at that conclusion.
Also, I find it somewhat uncomfortable that the name of the star sign I share has also been taken to specify a tragic condition that so many people suffer.
But, I've yet to hear of anyone that's lobbied astronomers to rename the Tropic of Cancer due to this.
But yes, 'Cancerian' would be grammatically correct and perhaps a little more accurate.
But I see no offense in your alias.
| Thank you |
| This is soooo off topic now... but: speaking as someone who is watching their wife die a little more each day from cancer (brain tumors), I can honestly say I don't give a damn what your nickname is.|
The illness "cancer" takes it's name from the astrological starsign Cancer - The Crab.
Wikipedia says thus:
Hippocrates described several kinds of cancers. He called benign tumours oncos, Greek for swelling, and malignant tumours carcinos, Greek for crab or crayfish. This strange choice of name probably comes from the appearance of the cut surface of a solid malignant tumour, with a roundish hard center surrounded by pointy projections, vaguely resembling the silhouette of a crab. He later added the suffix -oma, Greek for swelling, giving the name carcinoma. Since it was against Greek tradition to open the body, Hippocrates only described and made drawings of outwardly visible tumors on the skin, nose, and breasts. Treatment was based on the humor theory of four bodily fluids (black and yellow bile, blood, and phlegm). According to the patient's humor, treatment consisted of diet, blood-letting, and/or laxatives. Through the centuries it was discovered that cancer could occur anywhere in the body, but humor-theory based treatment remained popular until the 19th century with the discovery of cells.
So, don't feel uncomfortable. The astrological sign came before the name of the illness.
And now, back to Blitz.
| You know I never imagined a nickname that didn't involve racial slurs, swearing etc would ever cause such an off-topic debate.|
Very sorry to hear about your wife.
I'm sincerely sorry to hear about what both you and your wife are going through.