PowerDraw 3 - Reading Pixel info

Started by
1 comment, last by SpannerBracket 21 years, 1 month ago
Hi all. Ive just started developing a game in PowerDraw (if you have a minute, take a look at this *very early* version - www.mode4.net/ben/shootemupv0.3.zip Ive got a question regarding reading pixel colours. First of all is there a way to read a pixel direct from the screen? Is it a case grabbing the screen area as a texture locking it out and then reading it? If so, how is this achieved? Secondly, can i read pixel colours from an image in my PowerImageList? Again, I don''t really understand what it means to lock out the image. I want to be able to read the pixel colours so i can perform per pixel checking on my ship, and also to add a couple of effects in the game. Any help would be great! Cheers Spanner
Advertisement
Greets.. to read pixels from the screen, you need to get the D3D surface out of it (please look further on this in DX9 SDK). Locking the surface means preventing access to it, while you read or write, since during concurrent access to the surface some pixel data might be loss due to the execution of multiple processes (when one process read the pixel, changes it and writes it to the destination, another process might interrupt and change the pixel after the other one read it... so finally when the first process writes the changed pixel, the change made by second process did not appear at all). In DX9 you need to lock the surface before any access is made, and by doing this, a pointer to the first pixel and scanline length (a length in bytes of horizontal viewable line) are returned. After you''ve made use of these, you need to unlock the texture, so it can be accessed by hardware and probably other processes, etc.
And finally, you can read a single pixel out of TAGFImage by using Image.Pixels[x,y] property (which is in 32-bit format).

Hope this helps,
Lifepower
Thanks Lifepower.. yes that is of help. Ill have a play tonight see if i can get the per pixel checking going.

And ill download the dx9 sdk and have a read through some of that... i would imagine thats gonna make for some heavy reading!

Cheers
Spanner

This topic is closed to new replies.

Advertisement