graphics and multimedia. outline introduction to multimedia loading, displaying and scaling images...

28
Graphics and Multimedia

Upload: corey-carr

Post on 25-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft

Graphics and Multimedia

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

Outline

•Introduction to Multimedia

•Loading, Displaying and Scaling Images

•Windows Media Player

•Adding a Flash Movie

•Microsoft Agent

Page 3: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft

Introduction to Multimedia

• Visual Basic 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

Page 4: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft

Loading, Displaying and Scrolling Images

• Visual Basic’s multimedia capabilities– Graphics– Images– Animations– Video

• Image manipulation

Page 5: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft

1 ' Fig. 16.23: DisplayLogo.vb2 ' Displaying and resizing an image.3 4 Public Class FrmDisplayLogo5 Inherits System.Windows.Forms.Form6 15 Private mGraphicsObject As Graphics16 Private mImage As Image17 18 ' sets member variables on form load19 Private Sub FrmDisplayLogo_Load(ByVal sender As _20 System.Object, ByVal e As System.EventArgs) _21 Handles MyBase.Load22 23 ' get Form's graphics object24 mGraphicsObject = Me.CreateGraphics25 26 ' load image27 mImage = Image.FromFile("images/Logo.gif")28 29 End Sub ' FrmDisplayLogo_Load30

Uses Form method CreateGraphics to create a Graphics object associated with the Form

The Image method FromFile retrieves an image stored on disk and assigns it to mImage

Page 6: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft

33 Private Sub cmdSetButton_Click (ByVal sender As System.Object, _34 ByVal e As System.EventArgs) Handles cmdSetButton.Click35 36 ' get user input37 Dim width As Integer = Convert.ToInt32(txtWidth.Text)38 Dim height As Integer = Convert.ToInt32(txtHeight.Text)39 40 ' if specified dimensions are too large display problem41 If (width > 375 OrElse height > 225) Then42 MessageBox.Show("Height or Width too large")43 44 Return45 End If46 mGraphicsObject.Clear(Me.BackColor) ' clear Windows Form47 48 ' draw image49 mGraphicsObject.DrawImage(mImage, 5, 5, width, height)50 End Sub ' cmdSetButton_Click51 52 End Class ' FrmDisplayLogo

If the parameters are valid, Graphics method Clear is called to paint the entire Form in the current background color

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

Page 7: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft
Page 8: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft

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:

Page 9: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft

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.

Windows Media Player

Page 10: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft

4. The windows media player control should now be in your Toolbox

5. Drag the control over a form and size it as needed.

Windows Media Player

Page 11: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft
Page 12: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft
Page 13: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft
Page 14: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft

Adding Flash MovieIn order to play the Flash movie in your VB.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.

Page 15: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft

Example

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load

AxShockwaveFlash1.Movie = "D:\nabd.swf" AxShockwaveFlash1.Play()

End SubEnd Class

Page 17: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft

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).

Page 18: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft

• 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.

• You can view this example at: http://www.microsoft.com/msagent/sdk/samples/html/peedypza.htm

Microsoft Agent

Page 19: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft

Fig. 16.28 Peedy introducing himself when the window opens.

Page 20: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft

• 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.

Microsoft Agent

Page 21: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft
Page 22: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft

In addition to the Microsoft Agent object myAgent (of type AxAgent) that managesall the characters, we also need an object (of type IAgentCtlCharacter) to representthe current character. We create this object, named mSpkr,

Page 23: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft
Page 24: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft
Page 25: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft
Page 26: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft
Page 27: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft
Page 28: Graphics and Multimedia. Outline Introduction to Multimedia Loading, Displaying and Scaling Images Windows Media Player Adding a Flash Movie Microsoft