PDA

View Full Version : Making an Image Browser


Desmond
09-26-2003, 03:06 PM
<HTML> <HEAD> <TITLE>AutoPlay Media Studio 5.0 Knowledge Base</TITLE> </HEAD> <BODY> <h3>Making an Image Browser</h3> <b>Document ID: IR10046</b> <hr> The information in this article applies to: <ul> <li>AutoPlay Media Studio 5.0 Professional Edition</li> </ul> <hr> <h3>SUMMARY</h3> <p>This article describes how to make an image browser.</p> <h3>DISCUSSION</h3> <p>As an example, we will create an application that has the user select a folder on his drive, and then populates a listbox object with all of the *.png and *.jpg files within that directory. The user clicks on a file in the listbox object, and clicks the "Open" button to load the selected image into the image object.</p> <ol> <li>Create a project with two button objects, a listbox object, and an image object.<br> <br> </li> <li>Label Button1 "Load" and Button2 "Open".<br> <br> </li> <li>Insert the following code into the On Click event for Button1:<code><pre>--Disable listbox Updating
<br />ListBox.SetUpdate("ListBox1", false);
<br />--Get the desired folder to browse
<br />folder = Dialog.FolderBrowse("Open Folder", "C:\\");
<br />--populate tables with all the .jpg and .png files
<br />file_jpg = File.Find(folder, "*.jpg", false, false, nil);
<br />file_png = File.Find(folder, "*.png", false, false, nil);
<br />images = {file_jpg, file_png};
<br />--do the following for each file:
<br />for k in images do --loops through the different image types
<br /> for j,file_path in images[k] do --loops through each image file
<br /> --add the item to the listbox, with the name visible and path as data
<br /> ListBox.AddItem("ListBox1", String.SplitPath(file_path).Filename, file_path);
<br /> end
<br />end
<br />
<br />--Allow the listbox to display the updated content
<br />ListBox.SetUpdate("ListBox1", true);</pre></code> </li> <li>Insert the following code into the On Click event for Button2:<code><pre>selected = ListBox.GetSelected("ListBox1");
<br />for j,k in selected do
<br /> Image.Load("Image1", ListBox.GetItemData("ListBox1", k));
<br />end</pre></code> </li> </ol> <p>KEYWORDS: AutoPlay Media Studio 5.0, Actions, Image, Set, Get, Opacity, Transparency </p> <hr> <FONT SIZE=1> Last reviewed: September 26, 2003<br> Copyright © 2003 <A HREF="http://www.indigorose.com" target="blank">Indigo Rose Corporation</a>. All rights reserved.<br> </FONT> </BODY> </HTML>