|
-
July 15th, 2005, 08:50 PM
#1
getting RGB from a 16-bit bitmap
Hey, you guys seem to be the best programmers around, so I've got a question to ask you.
I'm writing a program that detects pixels off the screen, and reacts accordingly. I've designed it to be as fast as possible, so I've done the following:
Made the program wait for printscr to be pressed, allowing windows to copy the data to the clipboard.
Tested, Opened, and Read in the clipboard HANDLE (as a HBITMAP)
called GetDIBits to read in the colour data (the only important part)
Now, I copy the buffer to stdin and fill out a 2d array. its an 800x600 picture at 16-bit colour, so I have a 2d array at [800*2][600] size, 2 bytes (16 bits) per pixel. Ill say this method is VERY fast. it clocks in at about 70ms including my Sleep(50) that I put in to allow time for the screenshot to be copied.
But now I can't read the colour. Thats my problem. With a 24-bit bitmap you can see the R, G, and B quite easily because they have their own bytes for each. All I know is that there is a colour table and this somehow relates to the 16-bits... not helpful eough for me, I'm afraid. How do I turn these 2 bytes into R, G, and B?
Instead should I just 'rebuild' the bitmap into memory, and use GetPixel on it? Got any other ideas for fast pixel scanning?
EDIT - maybe this should be in 'graphics programming' - can a mod move it there?
Last edited by TiMBuS; July 15th, 2005 at 11:57 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|