Click here to Skip to main content
15,905,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am creating the video player in that i am drawing shapes using GDI+. By using this i can draw the shapes over the panel. But i need to select the drawn shapes to move & re-size dynamically [To make it more user friendly]. What i have to do to achieve this!?

Thanks & regards,
J.Surjith Kumar
Posted
Updated 11-Jun-13 20:14pm
v3
Comments
joshrduncan2012 11-Jun-13 9:05am    
What have you tried so far to accomplish this?
J.Surjith Kumar 11-Jun-13 10:22am    
I tried by creating the glass panel for each and every drawings dynamically but when i play the video, the shapes which i drawn over the glass panel was flickering.
JackDingler 11-Jun-13 15:04pm    
You have to be sure that your code draws after each frame, before the frame is blitted to the DC. i don't know specifically how to do this in DirectX, but there should be a call that allows you to hook into the frame for post processing.

1 solution

There are two common methods for doing this.

1. Check you cursor coordinates against each shape to see if it comes near any primitive. The downside of this technique is that the more shapes you have on the screen, the more need you'll have for optimizations to prune the selections down, before doing the math to determine if your cursor and shapes are close enough together to count as a selection.

2. With every draw to the screen DC or memory DC, also draw to a memory DC using a false color determined by an ID for the shape or primitive. For this operation disable anti-aliasing, it is designed to smudge the pixel colors and will corrupt the IDs. With a 32 bit bitmap, you can use a DWORD for the ID, giving you up to 2^32-1 shape primitives that can be viewed on the screen. To find the primitive, simply scan the pixels on the false color bitmap and choose the object that is closest to the cursor position. Be sure and paint the background with 0 before every draw. This technique requires no complex math and performs very fast look ups.

The look up for the second one, can be a simple scan of the pixels near the cursor. No need to scan the entire image.
 
Share this answer
 
v4
Comments
J.Surjith Kumar 11-Jun-13 10:14am    
Thanks for your valuable reply.. Can you give me any link or sample codes regarding this, it will be more useful for me to proceed further.
JackDingler 11-Jun-13 10:57am    
Alas I don't have any samples at this time. They all stayed with previous employers...

I suggest you try for #2, I believe it's the better solution.
Code for displaying objects on a memory DC with a bitmap selected are common.
You'll want to make your drawing functions a bit configurable so that they go to the DC you specify. This will allow you to get a visual representation of your ID map for testing. It's useful to see the map on demand, to determine if there are artifacts that are being drawn, that you don't want to select.

You may pass a renderoptions class (you define it) to your draw functions so that they can change behavior according to what sort of surface they are drawing to.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900