I'm trying to zoom into the area of the DirectShow window between Marker A and Marker B(It's a RangeBar) which represent the width of the video window.
I've tried using SetWindowPosition but all that does is move the video window around.
I'm new to DirectShow, please help !
Thanks !
You can use the IVMRMixerControl interface of the renderer to zoom in to a part of the video.
You need to switch the filter to "mixing-mode" (before you connect the filter) by calling IVMRFilterConfig::SetNumberOfStreams (2). Connect the Renderer. Now you can set the rect you want to show with a call to IVMRMixerControl::SetOutputRect. You need to provide the rectange you want see with normalized values. This means, if you want to zoom in you will set {-0.5, -0.5, 1.5, 1.5} and if you want to zoom back you will set {0, 0, 1, 1}.
Related
I created simple form and now I want to draw single objects (rectangle, circle, lines..) in relative coordinates.
Main problem for me here is to create 2D cartesian coordinate system in middle of the form.Is it possible and how to do it??
Main question is how to efficiently transform absolute coordinates to relative? How to create my own system so I get results in numbers (negative, positive depending on quadrant) and not in pixel?
.
Currently I made MouseMove event to display current location of mouse with Cursor.Position.X, Cursor.Position.Y and display it in label. Displayed coordinates are pixels, how to change that? I've read something about converting with PointToClient method but I don't really understand it.
I am tied to windows forms becouse I already made a program in win forms and now I just want to add this feature to it.
Thanks
What you're most likely looking for are Graphics.TranslateTransform and Graphics.ScaleTransform.
private void Transform(PaintEventArgs e)
{
e.Graphics.ScaleTransform(width, height);
e.Graphics.TranslateTransform(xOffset, yOffset);
}
You'll also need to make sure that whatever drawing method you're using has an overload for either PointF structures or Singles.
Of course, you could also just handle all of this on your end. Scaling your input/output coordinates by the width and height of the form and then translating by half of that will give you the same results.
Edit- To add some clarity, Windows always expects your coordinates to be in pixel form. You can use the above transformations to do your work at a different scale and then transform into the form that Windows expects.
Setting the translation should be straightforward. If you want the middle of the form, you simply want to translate by half the width and half the height. How you choose to scale your coordinates is going to depend on the range that you need to work in (ie, -1.0 to 1.0, -0.5 to 0.5, etc.).
I am creating a screen capture & crop utility using answer posted here
The code draws a rectangle (System.Drawing.Rectangle) on the screen and saves a cropped image.
I need to make this rectangle movable to a different area on the screen without changing the size.
How can I achieve this?
What did not work for me?
I tried this codeproject article, works very good to move controls on the screen.
For this code to work correctly I would need to draw rectangle on a container control.
Which container can be used to wrapping?
Being a succesful web developer I used to think that I can write for WinForms also... I was wrong :-( Some help would be much appreciated!
In C# Windows Forms to change the location of a rectangle you do the following
rect.Location = new Location(x,y);
Where x and y are the coordinates (relative to the window's origin) that you want to move it to.
Here's a link to The MSDN Page on System.Drawing.Rectangle
I want to get client area, I know the default answer is GetClientRect but what I get from that function is a rectangle starting at (0,0). So I can't use GetClientRect with CopyFromScreen.
Is there a way to get absolute coordinates with GetClientRect OR somehow learning the titlebar size etc. while using GetWindowRect?
I am using C#.NET.
Use PointToScreen to transform client coordinates to screen coordinates:
I can get the coordinates of a windows entire area, and the coordinates of the client area using the GetClientRect and GetWindowRect Win32 calls. My problem is that the GetClientRect always returns 0,0 for the top left. How do I figure out what the actual client region is relative to the window rect?
You can use ClientToScreen to get the coordinates of the upper left (0,0) point in screen coordinates. The RECT returned by GetClientRect will be appropriate to get you the lower right corner (just add to the POINT set by ClientToScreen).
Use ClientToScreen to convert the client coordinates to screen coordinates. The window rect (GetWindowRect) is already in screen coordinates, and includes the non-client area (borders, caption, etc)
And if you are working with WinForms then you can use PointToScreen instead of ClientToScreen for solution proposed by Reed Copsey.
The relation between window rect (with borders etc) and the client rect (inside borders) is most easily found using AdjustWindowRectEx(). Get the window style and ex style of the window, and call that function, to see how much border is on each side.
You can also use the MapWindowPoints function to convert an entire RECT to screen coordinates at once.
How can I show something on screen wihtout using forms?
Actually, I want to show some text and images popping on screen.
EDIT: just like i said HERE
What you can do is to create a alphatransparent form that draws the PNG and position it at the correct location and bind move etc.
http://www.codeproject.com/KB/GDI-plus/perpxalpha_sharp.aspx
PerPixelAlphaForm transparentImageForm = new PerPixelAlphaForm();
transparentImageForm.SetBitmap(<IMAGE GOES HERE>,<OPACITY GOES HERE>);
//opacity is the opacity that the image will be drawn with, a value of 255 = all transparent parts will be alpha/transparent just as much as the original PNG etc..
and you can put a timer that calls SetBitmap and changes the Opacity to fade in/out the image on the screen
And you can generate the text (on the fly) in a nice way with code from THIS article
and pass that image to the SetBitmap of the AlphaTransparent form.
EDIT: OR GO TO WPF.
I don't think you can: a form is equivalent to a window, and Windows applications draw into a window and not directly onto the screen (unless perhaps it's the backgroun/wallpaper, which I don't know about).
I think that's overdoing it but XNA will allow you to draw to the screen, but it is meant to be used for games so you will have trouble fitting it to a normal application.