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 / Geting the window contents as an image (or array of pixel values)...

Author
Message
MACRO
21
Years of Service
User Offline
Joined: 10th Jun 2003
Location:
Posted: 7th Jun 2008 21:21
Hi,

I have done a search both on this forum and through the help files and have found some useful looking functions like dbGetBackBuffer() but I am not entirely sure how to go about doing what I want.

What I am after is grabbing the render output from the DB window as effectively an image (or array of colour values).

dbGetBackBuffer() returns a DWORD which I believe is a pointer to the memory address of the back buffer but how do I actually access the data and what format is it likely to be?

Any ideas would be greatly appreciated

MACRO
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 7th Jun 2008 22:14 Edited at: 7th Jun 2008 22:18
Cast it to a DWORD*, i.e. DWORD* myBackbuffer = (DWORD*) dbGetBackbufferPtr(); then you can just read pixels like: DWORD whatever = myBackbuffer[1337]; The format will probably be in ARGB, where each component is 8bits, for a 32bit backbuffer at least. If this is the case it might be easier for you to create a struct of 4 bytes and cast it to this instead, i.e. struct Pixel{unsigned char a,r,g,b;};Pixel* myBackbuffer = (Pixel*) dbGetBackbufferPtr(); char alpha = myBackbuffer[1337].a;

MACRO
21
Years of Service
User Offline
Joined: 10th Jun 2003
Location:
Posted: 8th Jun 2008 19:13
Hey,

Thanks for the tip but this only seems to work fullscreen. Is there any way to get the buffer data in window mode?

Here is my test code, it just dumps the pixel RGB data out to a file for inspection...



This works fine in full screen mode but not in window mode. In window mode dbGetBackBufferWidth() and dbGetBackBufferHeight() return -1 and if you try to access the buffer everything crashes.

Is ther a way to make this work for window mode apps or is there another way to get a handle on the window data?

Cheers

MACRO

Login to post a reply

Server time is: 2024-11-17 17:34:27
Your offset time is: 2024-11-17 17:34:27