Jump to content
Xtreme .Net Talk

isilrion

Members
  • Posts

    20
  • Joined

  • Last visited

About isilrion

  • Birthday 08/25/1981

isilrion's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Code I didn't find my old code, but I managed to reproduce it... it has the same effect now: This is the transparent control (I want it to look like just a diagonal static line, and I want the rest to be invisible) class Transpanel : UserControl { public Transpanel():base() { this.SetStyle(ControlStyles.SupportsTransparentBackColor,true); this.SetStyle(ControlStyles.UserPaint,true); this.SetStyle(ControlStyles.AllPaintingInWmPaint,true); this.BackColor=Color.Transparent; } protected override void OnPaint(PaintEventArgs e) { e.Graphics.DrawLine(Pens.Red,0,0,this.Width,this.Height); } protected override void OnPaintBackground(PaintEventArgs e) { //Do nothing } } This works with static background, or when the background is updated on the 'onpaint'. Usually that's how it happens - but in my case, I'm calling it from: public class Form1 : System.Windows.Forms.Form { private UserControl panel1; private System.ComponentModel.Container components = null; public Form1() { InitializeComponent(); this.panel1.BackColor=Color.Transparent; Video v = new Video("c:\\videos\\prueba7.avi"); v.Owner=this; v.Play(); } protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.panel1 = new Transpanel(); this.SuspendLayout(); // // panel1 // this.panel1.Location = new System.Drawing.Point(48, 32); this.panel1.Name = "panel1"; this.panel1.TabIndex = 0; this.panel1.Height=20; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(292, 273); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.panel1}); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); } #endregion [sTAThread] static void Main() { Application.Run(new Form1()); } } I run this, and I don't get the control transparent (red line on a grey box on a moving video), wich has a lot of sense. I move it out of the screen and back in (mouse drag and drop) and it becomes transparent (I see the red line on top of the moving video) I haven't been able to reproduce it on another computer, but that's the effect I was looking for. I'm sure now, however, that it was a bug (but if it happened as a bug, perhaps there is a way to make it happen for real) Sorry for posting the whole code. I just wanted to make sure no one reading this would miss anything. Isilrion.
  2. Sorry, nick, my fault. My english is not as good as it should. I didn't express myself well enough. I have (had) the window playing the video, with the 'transparent' controls on it - only they weren't transparent at all. (by transparent I mean, with the transparent styles set, and doing nothing but painting a line on my onpaint). Then I moved the window out of the screen, and moved it back in (with the mouse, manually, dragging it), and surprise! the control was transparent now. I tried that on another computer, and it didn't become transparent. A weird bug in my computer, I guess. Let me dig up some code - if I find wich N in 'ApplicationN' is the one, I'll post it.
  3. No, I tried that. It is not my own control who is earsing itself in the paint method. It is the parent control who does. I can't do the double buffering, because I don't have access to the parent control surface. In fact, I think I started this thread for my own ignorance (I saw what I think now could possibly be a bug: and I was trying to reproduce it as it was nearly the desired effect) The 0x20 style was actually the answer to my question - though not the solution to my problem. If the parent paints in its 'onpaint' event, it does exactly what I what it to do. In my case, though, DirectX handles the painting and my app never knows about it. I guess I'll have to keep digging on how to use DirectShow's Overlay Mixer from C#, but that should go in the DirectX section. If any of you have done that/have any ide about how to do it, please let me know! (wrappers, code, etc). If not - it is not urgent now, i'll keep exploring, and I'll post here if and when I solve it. Thanks for the help. I learned a lot in this thread.
  4. Hmm... that might work. Still trying to make it work, though (nothing is getting painted, but I just copied/pasted that, I'll take a deeper look at the code - it seems that the video is erasing it). However, the transparency effect seems to be better than one achieved with the ControlStyles.SupportsTransparentBackColor. Thanks, I'll try to make it work, I'll let you know if it worked. What style is 0x20?
  5. Problem... solved? The problem was... solved? I tried to run it in yet another PC, and I kept getting the exception. I accidentally installed ACDSee 4.0 on that computer, and the problem disappeared. I had ACDSee 5.0 on my computer and on the other computer where it worked. So I installed ACDSee on the target computer and wow. It works. Of course... I can't see the relation between ACDSee and a Divx video file and .net and DirectX. I am closing my own thread (answering my own question) just in case that someone else finds this thread, he can also have the answer (though if anyone can explain to me the relation, please do!) Thanks Isilrion
  6. Hi. I've been having a problem... I made a little C# program with directX (a media player, using the DirectX 9 AudioVideoPlayback). The problem is, it runs perfectly on my computer, a friend told me it ran on his, but yesterday night the one who asked for the program brought me his computer because it refused to run on it. It has DirectX 9 installed, and the .NET framework. I copied some of the DX SDK samples to his PC, and the managed ones also refused to run (the non-managed, all ok) I got to the Direct9 setup, and tried to install the .cab that contains the managed DX (Is it necesary to do it manually?), and that got the managed samples to run, but my app (wich is essentially like one of the samples) still refused to. The best thing I managed to figure out is that it is throwing me an "InvalidCastException" (that is the java name of the exception, forgot c# name, but I'm referring to the exception with the same meaning). The line that causes the exception goes like this: VideoInfo vi = new VideoInfo(filename) filename being a string, and the VideoInfo constructor says public VideoInfo (string filename) { MessageBox.Show("Debug: construyendo VideoInfo con "+filename); Video v = new Video(filename); this.Duration = v.Duration; /// get some other data about the video. } As you can see, there is no cast there whatsoever. What boggles me more is that it throws the exception BEFORE showing the messagebox (thus, I never get to see the messagebox). And, I can call static methods of the VideoInfo class (that doesn't contain any reference to the video class). I also tried making a setup proyect to install the app, it created the AudioVideoPlayback dll (don't remember the full name), I copied it into the executable directory, and it still refused to work (At the other computer where the app worked, it refused to work without that dll, and began working as soon as I copied it) And, as a final step to my experiments, I commented out every line referring to the 'Video' class. Surprise. The messagebox appeared (though obviously my app didn't do what it was suposed to do) My question is, what could be happening? I'm about to format his hard disk and reinstall windows, framework and directx from scratch, but that makes no sense. Also, why does my app requires the AudioVideoPlayback dll in the same directory, and the samples in the SDK that use the AudioVideoPlayback namespace don't?
  7. Well, I think I did what you said, but nothing got displayed. I attached the DDraw device to the same control holding the video and filled a magenta rectangle in the while(true) loop. The rectangle never showed (running the prog w/o the video being rendered showed the rectangle). In a previous post you (Ryan) mentioned to draw 'underneath' the video. I didn't understand what you wanted to say with that, but today I was doing -another- web search, and I got to a page where a similar answer was given. I don't know exactly what they were talking about, but if that's what you meant, I think I could do some research about it. The quote is I also found in the samples something very similar to what I was looking for (a marquee, with transparent background, moving on the video), but it was using C++ & DirectShow. Should I search the DirectX threads for a way to use the [unmagaged] DirectShow on my app? thnx again.
  8. Let me see if I got you (my english isn't nearly as good as it should be). I'm playing the movie on a panel. I have no problem with playing it on a inherited control, if that's what you mean. Now, if I create a new DirectDraw device on that control, will it be the same as the one playing the video? (That's what I understood from your reply). And painting the text directly there on a while(true) kind of loop (that's also what I understood)... wouldn't that be very cpu expensive, and with a lot of flickering? (I guess I can answer that question myself after I get to my computer) And about the lot of work setting up D.Draw, I already got a marquee working on it, I just haven't been able to put it on the movie. Thanks. Isilrion
  9. Ah, just in case there is a better soltion I haven't thought about. The original idea was to show a marquee on the bottom of the video, like those that appear on some movies saying 'This movie is copyrighted, bla bla bla', and from the beggining I was thinking on painting the text and not use labels, but right now, anything will do.
  10. Yes, that was my guess. Now I have a couple of questions: 1-) Is there any way to play a video to GDI/GDI+? 2-) Alternatively (and possibly better), how can I use directdraw to draw over the video? I haven't managed to tell AudioVideoPlayback to draw over a DirectDraw surface, so I don't know where to paint. It draws it to Direct3D (the sample uses D3D), but not D.Draw. thanks.
  11. Please do. I'll really appreciate it. Thanks.
  12. Yes, I'll post some code. I don't have it now (I'm on another computer), but I'll try to post it tomorrow. Well, I wasn't overriding the video controls OnPaint. I did, however, attach a PaintEventHandler to it, and it wasn't getting called. (can it have something to do with the fact that is DirectX/AudioVideoPlayback who is playing the video, like I said before?) The control that I'm trying to paint transparent is just a subclass of UserControl. Originaly I wanted to make a label with transparent background, now I at least want to have a way to draw text over the video. And I set my UserControls ControlStyle like you said before my last reply. Thanks again.
  13. That explains a few things, then. I guess I'll have to forget about DirectDraw and begin playing with Direct3D. The question changes a bit then. Can I use Direct3D to do 2D animations? (2D text, 2D sprites over 2D video?) I mean, without creating a big cube 'looking' at the screen and drawing triangles on it. And if I can, how? On top of everything, the AudioVideoPlayback\Texture sample won't run on my PC, throws an exception (that I can't copy right now, but the only *word* it has is 'exception')
  14. Hmm. This is weird. I haven't tried painting directly on the video, but I don't think it will work. The OnPaint method of my control doesn't get called after every frame (I added a MessageBox.Show to my OnPaint and OnPaintBackground methods to see when they get called - it only shows when I force it to repaint (like covering the window with another). Even then, the painting is erratic. If I enable the doublebuffer like you did, the background gets painted of black *after* leaving the OnPaint method (my guess: backbuffer is black and it never changed color?). I've tried painting the background with the Color.Transparent and the Color.fromARGB(0,0,0,0) in my OnPaint -still all black. But, right before the OnPaint finishes, I *almost* get what I'm looking for (the 'debug' messageBox is the last instruction on my OnPaint). If I don't use the DoubleBuffer style, I almost get what I'm looking for (the same *almost*). When I hide the window (not minimize, not covering with another window, but moving the control off-screen and then moving it back in quickly), I get the desired effect on some random regions of the control. On the rest of the control, I either get the same black or grey background, or the form background, whatever is behind the form (usually a piece of the VS.NET IDE). Ah, the effect is exactly the same wether I call base.OnPaint/base.OnPaintBackground or not. BTW, how do I get the graphics object asociated with a control? I'm used to Java's '.getGraphics()'. Thanks.
  15. Yes, it renders the video using the .RenderToTexture method of the AudioVideoPlayback class. (I think that's the name of the method). The problem with it is that it renders it to a Direct3D device/surface/texture, wich I can't use/don't know how to use in DirectDraw.
×
×
  • Create New...