1 / 28

Graphics and Multimedia In visual Studio. Net (C#)

Graphics and Multimedia In visual Studio. Net (C#). Outline. Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft Agent. Introduction to Multimedia.

decker
Télécharger la présentation

Graphics and Multimedia In visual Studio. Net (C#)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Graphics and MultimediaIn visual Studio. Net (C#)

  2. Outline • Introduction to Multimedia • Loading, Displaying and Scaling Images • Windows Media Player • Adding a Flash Movie • Microsoft Agent

  3. Introduction to Multimedia • Visual studio offers many convenient ways to include images and animations in programs • Computing field decades ago mainly used computers to perform arithmetic calculations • We are beginning to realize the importance of computer’s data-manipulation capabilities • Multimedia programming presents many challenges • Multimedia applications demand extraordinary computing power

  4. Loading, Displaying and Scrolling Images • C# multimedia capabilities • Graphics • Images • Animations • Video • Image manipulation

  5. The Image method FromFile retrieves an image stored on disk and assigns it to image Uses Form method CreateGraphics to create a Graphics object associated with the Form 1 // Fig. 16.23: DisplayLogoForm.Cs 2 // Displaying and resizing an image. 3 4 // Create class inherits from System.Windows.Forms.Form 4 PublicClassDisplayLogoForm: System.Windows.Forms.Form 5 { // Declaration for all controller Private System.Windows.Forms.Form.ButtonSetButton; ……………………………………………. ……………………………………………. // Declaration of image and graphicsObject variables 15 Private Image image = Image.FormFile(“images/Logo.gif”); // load image 16 Private Graphics graphicsObject; 17 18 // Sets member variables on constructor Public DisplayLogoForm() { InitializeComponent(); // create object graphicsObject graphicsObject= this.CreateGraphics(); }

  6. If the parameters are valid, Graphics method Clear is called to paint the entire Form in the current background color Private void SetButton_Click((object sender, EventArgs e) { // get user input int width = Convert.ToInt32(WidthTxtBox.Text); 38 Int height = Convert.ToInt32(HeightTextBox.Text); // If specified dimensions are too large display problem If (width > 375|| height > 225) { 42 MessageBox.Show("Height or Width too large"); 43 Return ; 44 } // Clear Windows Form 46 graphicsObject.Clear(this.BackColor); 47 48 // Draw image 49 graphicsObject.DrawImage(image, 5, 5, width, height); 50 } // End Method SetButton_Click 51 52 } ' End Class DisplayLogoForm Graphics method DrawImage is called with the following parameters: the image to draw, the x-coordinate of the upper-left corner, y-coordinate of the upper-left corner, width of the image, and height of the image

  7. Windows Media Player • Windows Media player • Enables an application to play video and sound in many multimedia formats • Motion Pictures Experts Group (MPEG) • Audio-Video Interleave (AVI) • Windows wave-file format (WAV) • Musical Instrument Digital Interface (MIDI) • To use the Windows Media Player control, programmers must add the control to the Toolbox. This is accomplished as following:

  8. Windows Media Player 1. Go to ToolBox  Choose Items... 2. Click on the COM Components tab and scroll down near the bottom of the List. Look for Windows Media Player.3. When you have found Windows Media Player, check the box beside it and click on Ok.

  9. Windows Media Player 4. The windows media player control should now be in your Toolbox 5. Drag the control over a form and size it as needed.

  10. Adding Flash Movie In order to play the Flash movie in your C#.NET application, you should add Shockwave Flash component as COM reference in your project and use Shockwave control added in the Toolbox. The following steps shows you the way: 1. In Solution Explore, right click References and choose Add Reference. In COM tab, add Shockwave Flash.   2. Right click Toolbox -> Click "Choose Items", in COM Components tab, choose Shockwave Flash Object, then you can see the control in the Toolbox. 3. Drag and drop the Shockwave control on the form, you may get "Failed to import the ActiveX control. Please ensure it is properly registered." error message. Click OK. 4. Right click the project name in Solution Explorer, choose "Rebuild". When the project rebuild successfully, you are able to add the Shockwave control on the form this time.

  11. Example

  12. Make sure that you have the latest version of Shockwave and Flash Player.http://sdc.shockwave.com/shockwave/download/download.cgi (Shockwave)http://www.adobe.com/shockwave/download/do...=ShockwaveFlash (Flash Player)

  13. Microsoft Agent • Microsoft Agent • Microsoft Agent is a technology used to add interactive animated characters to Windows applications or Web pages • Microsoft Agent control provides programmers with access to four predefined characters: Genie (a genie), Merlin (a wizard), Peedy (a parrot), and Robby (a robot).

  14. Microsoft Agent • Microsoft provides basic information on Agent technology at its Web site: www.microsoft.com/msagent • This section introduces the basic capabilities of the Microsoft Agent control. For complete details on downloading this control, visit: http://www.microsoft.com/msagent/downloads/user.aspx • The following example, Peedy’s Pizza Palace, was developed by Microsoft to illustrate the capabilities of the Microsoft Agent control. • Youcan view this example at:http://www.microsoft.com/msagent/sdk/samples/html/peedypza.htm

  15. Fig. 16.28 Peedy introducing himself when the window opens.

  16. Microsoft Agent • To use MS Agent, you have to add to your ToolBox: 1. Go to ToolBox  Choose Items... 2. Click on the COM Components tab and scroll down near the bottom of the List. Check MS Agent Control. 3. Drag it to your form • Before running any code, you first must download and install the control, speech recognition engine, text to speech engine and the character definitions from the Microsoft Agent Web site listed previously.

  17. In addition to the Microsoft Agent object AxAgent1(of type AxAgent) that manages all the characters, we also need an object (of type IAgentCtlCharacter) to represent the current character. We create this object, named speaker,

More Related