12
Microsoft® Small Basic Flickr, ImageList, and Network Objects Estimated time to complete this lesson: 1 hour

2.6 flickr, image list, and network objects

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: 2.6   flickr, image list, and network objects

Microsoft® Small Basic

Flickr, ImageList, and Network Objects

Estimated time to complete this lesson: 1 hour

Page 2: 2.6   flickr, image list, and network objects

Flickr, ImageList, and Network Objects

In this lesson, you will learn about:

Using different operations of the Flickr object.

Using different operations of the ImageList object.

Using different operations of the Network object.

Page 3: 2.6   flickr, image list, and network objects

The Flickr Object

Small Basic provides the Flickr object with two operations– GetPictureOfMoment and GetRandomPicture.

Flickr! You can access this online image-hosting Web site right from within your Small Basic program.

Let’s explore each of these operations…

Page 4: 2.6   flickr, image list, and network objects

The Flickr Object

You can use the GetPictureOfMoment operation of the Flickr object to get the URL for Flickr’s picture of the moment.

You can then retrieve and display that image in your program by using the DrawImage or DrawResizedImage operations of the GraphicsWindow object.

Page 5: 2.6   flickr, image list, and network objects

The Flickr Object

You can use the GetRandomPicture operation of the Flickr object to get the URL of a random picture, which has the same tag in Flickr as the tag you specify.

For example, if you want your desktop wallpaper to change to five different landscape photos, you can simply use the GetRandomPicture operation and specify the tag as “landscape” in the following manner.

After you run the program, you see that your desktop wallpaper changes to five different landscape images every 10000 milliseconds (10 seconds).

Page 6: 2.6   flickr, image list, and network objects

Continuing our discussion about images… Let’s look at another object offered by Small Basic that allows you to add specific images in your program.

The ImageList Object

This is the ImageList object.

You can use the ImageList object to load images from a specific location and store them in memory. The ImageList object provides the following operations:

LoadImage—This operation loads the stored image from a local file or the Internet into the memory of your computer. You must specify the name or the URL of the file you want to load.

GetHeightOfImage—This operation retrieves the height of the stored image. When using this operation, you must specify the name of the image file.

GetWidthOfImage—This operation retrieves the width of the stored image. When using this operation, you must specify the name of the image file.

Page 7: 2.6   flickr, image list, and network objects

Let’s see how you can use the various operations of the ImageList object…

The ImageList Object

Let’s look at this with an example…

The height and width of the image is retrieved by using the GetHeightOfImage and GetWidthOfImage operations.

The GraphicsWindow is then set to the same size of the image.

Now, we draw the loaded image on the GraphicsWindow.

OUTPUT

Page 8: 2.6   flickr, image list, and network objects

The Network Object

As you see, the Network object provides two operationsDownloadFile and GetWebPageContents.

You may sometimes want to include a certain file in your Small Basic program. This file may be available on your local network or as a Web page on the Internet.

To retrieve the required file from the network, you can use the Network object in Small Basic.

Let’s learn more about these operations and how to use them…

Page 9: 2.6   flickr, image list, and network objects

The Network Object

You can use the DownloadFile operation of the Network object to download a file from the network to a temporary file on your local computer. You need to specify the location of the file on the network.

The output window displays the location of the downloaded file on your computer.

Page 10: 2.6   flickr, image list, and network objects

The Network Object

OUTPUT

You can use the GetWebPageContents operation of the Network object to get the contents of a specified Web page.

In this case, the output window displays the HTML code of the Web page, “http: //www.microsoft.com/”.

Page 11: 2.6   flickr, image list, and network objects

Let’s Summarize…

Congratulations! Now you know how to:

Use different operations of the Flickr object.

Use different operations of the ImageList object.

Use different operations of the Network object.

Page 12: 2.6   flickr, image list, and network objects

It’s Time to Apply Your Learning…

Write a program that performs the following operations:

Load 10 images of animals from Flickr.

Set the height and width of the graphics window similar to that of the images.

Display the downloaded images in the graphics window.

Change the image every 2000 milliseconds.