Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / getPixelsPointer function

Author
Message
Smoke sheath
18
Years of Service
User Offline
Joined: 19th May 2006
Location:
Posted: 4th Jun 2006 12:13
Hiyes ppl,

Working on a routine to perform a partial fade on areas of the screen.

screenPtr = dbGetPixelsPointer();

gives me what looks like the correct mem address but when i try to

pixColour = *screenPtr;

i get access violations. The help manual suggests indirection should work and would be quicker than dbPoint() and dbDot().

I have used dbLockPixels() prior to screen access and dbUnlockPixels afterwards although the code isnt running though to that point, (otherwise dbGetPixelsPtr would return NULL)

I also have two separate versions of this function, (not that it should affect this problem but ...) One where pixColour is defined as DWORD for 32bit screen depth and consequently one where it is defined as a WORD for 16 bit screen depth.

I just wanted to avoid having nested loops (x direction and y direction) with the overhead of what is essentially two unnecessary function calls.

Suggestions please folks ?
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 5th Jun 2006 16:57
Maybe you are talking about something like this:



Of course you have to provide screen positions and RGB components.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Jun 2006 19:24
You shouldn't get the pixel pointer without locking first - DirectX doesn't guarantee that the address will stay the same unless you lock. That's what may be causing your access violations.

For free Plug-ins and source code http://www.matrix1.demon.co.uk
Smoke sheath
18
Years of Service
User Offline
Joined: 19th May 2006
Location:
Posted: 5th Jun 2006 19:35
Yup, I had the following...
NB This is to play around with a square at an offset on the screen
NB and to make it grey but semi-trans



however as soon as i debug to:
pointCol = *writePtr;

I get an access violation. As i stated the mem address looks right for the screen, but if i replace:

pointCol = *writePtr;
with
pointCol = dbPoint();

and
*writePtr = pointCol;
with
dbDot( ... );

it all works fine but I am also getting an overhead of two unnecessary function calls within a nested loop 8/
Smoke sheath
18
Years of Service
User Offline
Joined: 19th May 2006
Location:
Posted: 5th Jun 2006 22:41
Sorry - last post didnt work right - should have had this code attached. (frustrating - have to wait to have posts checked 8/ )

This was the code i was using:


dbLockPixels();

pixPtr = dbGetPixelsPointer();

offsetPtr = pixPtr + (posY * pixelPitch) + (posX * bytesPerPixel);

for (yLoop = some; yLoop < lots; yLoop++)
{
for (xLoop = some; xLoop < lots; xLoop++)
{
writePtr = offsetPtr + (yLoop * pixelPitch);
writePtr += (xLoop * bytesPerPixel);

// at this point I *should* be able to go
pointCol = *writePtr;

// play around with the colour and then ...
*writePtr = newPointColour;
}
}

dbUnlockPixels();




however as soon as i debug to:
pointCol = *writePtr;

I get an access violation. As i stated the mem address looks right for the screen, but if i replace:

pointCol = *writePtr;
with
pointCol = dbPoint();

and
*writePtr = pointCol;
with
dbDot( ... );

it all works fine but I am also getting an overhead of two unnecessary function calls within a nested loop 8/

Login to post a reply

Server time is: 2024-11-19 06:40:13
Your offset time is: 2024-11-19 06:40:13