Page 1 of 1

d3d screenshots -> returning RGB values and coordinates ?

Posted: Fri Sep 15, 2006 4:44 pm
by K.puts
hello,
i found code in this forum to make screenshots with d3d engine,
thank u very much for that !

is it possible to return the rgb values and x,y, coordinates from the captured image (in an array?), before saving as image.

this is the code :

Code: Select all

If d3d\CreateDevice(#D3DADAPTER_DEFAULT, #D3DDEVTYPE_HAL, hWnd, #D3DCREATE_SOFTWARE_VERTEXPROCESSING , @d3dpp, @d3dDevice.IDirect3DDevice8) = #D3D_OK
  If d3dDevice\CreateImageSurface(ddm\Width, ddm\Height, #D3DFMT_A8R8G8B8, @surface.IDirect3DSurface8) = #D3D_OK
    If d3dDevice\GetFrontBuffer(surface) = #D3D_OK
      
;-
  If D3DXSaveSurfaceToFileA("c:\filename.bmp", #D3DXIFF_BMP, surface, #Null, #Null) = #D3D_OK
        Debug "screenshot saved!"
;- 

     EndIf
    EndIf
  EndIf
EndIf 

Re: d3d screenshots -> returning RGB values and coordinat

Posted: Fri Sep 15, 2006 9:14 pm
by traumatic
K.puts wrote:thank u very much for that !
You're welcome! ;)

Why not try using D3DXSaveSurfaceToFileInMemory() ?

The D3DXBUFFER the image is being saved to contains the method GetBufferPointer()
which should give you the entire image as a BMP. It's fairly easy to retrieve the needed
rgb values from that.

Posted: Fri Sep 15, 2006 9:38 pm
by K.puts
Hi,
wonderful, thanx for this information, i will see to get some infos about how the bits are sorted in memory after using this function - to handle them correct.

i am new in this stuff, i just wanted to prog a little color-choose and color-search tool and used getpixel_(), but it was aweful slow :-)

i have searched several pure,vb, directx and c forums for code examples last days (bitblts, getdibits,...), my head's burning, but now i give it a new try
:twisted:

cya

Edit: I'm coming from germany, too, berlin ->Grüss Dich :)

Posted: Sat Sep 16, 2006 8:41 am
by traumatic
K.puts wrote:Edit: I'm coming from germany, too, berlin ->Grüss Dich :)
Ik glob ik tille, wa ;)

Welcome to the forums, have fun exploring the breathtaking world of DX. :)