|
-
Jan 26th, 2011, 09:43 AM
#1
Thread Starter
Addicted Member
Make image grey and rectangle area colour...
I have created a screen capture functionality in my application that captures the entire desktop and then displays this in a picturebox on a form that is maximised. The user then can define a rectangle by draging there cursor which at the moment displays a red rectangle. What I would like to do is make the image black and white and then as the user defines their rectangle display the content of the rectangle in colour.
I have googled for ages trying to find something on this, but with no luck.
To illistrate this better they are using the same functionality in snagit 10, please see below link to a page that has a video link showing this (55 sec into video)
http://www.techsmith.com/snagit/features/win/
Thanks
Simon
-
Jan 26th, 2011, 05:00 PM
#2
Re: Make image grey and rectangle area colour...
Logically it's very simple.
1. Get your screen capture in color
2. If using GDI+, can render the capture to the screen (form, picturebox, whatever) using ImageAttributes
3. If not using GDI+, can create a secondary bitmap and grayscale the color image to that bitmap. Display the grayscale bitmap on the screen
4. When dragging, replace color section (previously selected area) with the grayscale version and replace grayscale section (newly selected area) with the color version using BitBlt, GDI+, VB's PaintPicture or something else that is applicable.
-
Jan 26th, 2011, 05:22 PM
#3
Thread Starter
Addicted Member
Re: Make image grey and rectangle area colour...
LaVolpe,
Thanks for your input, I am using GDI+.
I am able to capture the screen in colour, and I know how to change the colour image to black and white using GDI+. However the things I am having a problem with is being able to display the colour area in the rectangle. I don't suppose you would be able to give me an example of some code?
Thanks in advance
Simon
-
Jan 26th, 2011, 05:34 PM
#4
Re: Make image grey and rectangle area colour...
If using .Net, then I'm not going to be able to help directly. I'm a VB6 user and fluent with GDI+. This is how I might try to do it in VB6. Since VB6 and .Net GDI+ syntax is different, I'll use simple terms, not syntax.
1. Get screen capture into GDI+ image. I'll refer to this as the primary
2. Create a secondary image, same size as primary. I'll refer to this as the buffer
3. Create a Color Attributes object/handle that enables grayscaling (matrix)
4. Render the primary in grayscale to the Buffer by applying that color attributes handle/object
5. Render the buffer to screen
6. When rectangle changes then
a. Using previous rectangle size. Render primary to buffer with attributes (grayscale)
b. Using updated rectange size. Render primary to buffer without attributes (color) - so newest area is in color
c. Render buffer to screen to include minimal space encompassing both rectangles. For initial tests, rendering entire buffer to screen can be done. But ideally, you don't want to do this in the final phase; much slower than updating a potentially much smaller section of changed image data.
Edited: If you get that far, then optimizing would be a next step. You don't necessarily need to render the previous rectangle entirely. But only the portion of it that isn't included in the new rectangle. In non-.Net, I'd use the IntersectRect API and/or apply clipping rectangles/regions as needed. Just an idea.
Last edited by LaVolpe; Jan 27th, 2011 at 07:49 PM.
Reason: got 6a & 6b turned around a bit
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
|