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 / How to get a pixel from an image

Author
Message
prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 29th Oct 2009 15:07
I have a camera which updates what I see below me and puts it to an image. How can I get the colour of the middle pixel of this image? I've tried bitmaps, but it doesnt allow you to copy images to them, so dbPoint can't be used (who invented bitmaps? id like to shoot them )


Your signature has been erased by a mod
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 29th Oct 2009 21:59
Can you transfer it to a memblock and look at it there?

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 29th Oct 2009 23:24 Edited at: 30th Oct 2009 00:22
hmm i've never used memblocks, i'll look at the commands now

EDIT: wow, dbMakeMemblockFromImage() then dbMakeBitmapFromMemblock(), seems easy

EDIT2: what would be wrong with this?



? It doesn't do anything


Your signature has been erased by a mod
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 30th Oct 2009 01:01
@prasoc
You can put an image onto a bitmap using 'dbPasteImage'.

Bitmaps are equivalent to Direct3D surfaces, which are themselves directly related to the internal workings of all graphics cards. OpenGL has an equivalent too.

Also, using 'dbPoint' is VERY slow.
Please explain what you actually need this for, because it is more than likely that you are simply going about it the wrong way. (You should almost never need to transfer information back from the graphics card to CPU memory).

Ian G
16
Years of Service
User Offline
Joined: 3rd Jun 2008
Location: SSM, Canada
Posted: 30th Oct 2009 01:42
There is also a command called dbGetImage( int iID, int iX, int iY, int* piR, int* piG, int* piB ); its defined in DarkSDKImage.h and is undocumented. I've never used it but its worth looking into (I'm not sure if it needs the image locked or not, or even if it works for that matter). I don't know if its faster than the proposed methods, but its worth looking into as converting to a memblock can be slow (at least whenever I used it) and as Diggsey mentioned, dbPoint is also slow. I think the next best way would be to convert to memblock and read the pixel data directly by figuring out which dword in the data is the middle (or whatever pixel you want to read) and use dbMemblockDWORD to get the colour value.
prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 30th Oct 2009 02:23
What I am trying to do is get the colour below my character so I can set my gun's ambient to that, bypassing the need for dynamic lighting on my gun/arms. Is there any easy way of doing this? ATM, I'm using 1 more camera, the dbPoint() function, etc. which lags it and it doesn't do anything :S


Your signature has been erased by a mod
prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 7th Nov 2009 16:03
So can anyone help? When I set my camera image to a memblock, the memblock size stays at 0, but when I use a static image (dbLoadImage) it gives the correct size. Why does it do this?


Your signature has been erased by a mod

Login to post a reply

Server time is: 2024-10-01 16:34:27
Your offset time is: 2024-10-01 16:34:27