livecode.com
  • Home
  • Download
  • Developers
  • Academy
  • Community
  • Store
  • Support
  • About
LiveCode Lessons » How To - Step-By-Step Guides To Tasks In LiveCode » How to Create a Thumbnail Image

Topics

  • Creating User Interfaces 22
    • Using Tab Buttons
    • How to create a rollover button with icon images
    • How to apply the new graphics effects to an object
    • How to make a stack with a window shape
    • How do I Send Messages During A Drag Operation?
    • How to show the progress of a download
    • How do I populate a field when an option menu is changed?
    • How do I scroll a card that is taller or wider than the window?
    • Creating Hypertext Links in Fields
    • How do I use the same controls on multiple cards?
    • Pinning Drag-and-drop to the mat: a primer
    • Detecting changes in a field
    • How do I use a Progress Bar?
    • How to manage and position objects when a stack is resized
    • How do I move between cards in my stack?
    • Play Sounds
    • How do I display a PDF in Rev?
    • How do I Create an ANSI Font Menu?
    • How to make a simple line graph
    • How to build an interactive plotter with a polygon
    • How To Create a Custom Cursor
    • How do I use Relayering?
  • Text 9
    • How Do I Use UTF-8 Text With Fields?
    • How do I Display Tab Delimited Text in a Table Field?
    • How can I search delimited data for a matching string?
    • How do I use Unicode in Rev?
    • How to count upper and lower case characters
    • Using the flagged property in a field
    • How do I style paragraphs in a field in LiveCode 5.5?
    • How do I display a table in a field?
    • How do I use hierarchical list support?
  • Working with files 9
    • How to list the files in a folder
    • How to read in data from an XML file
    • File Input/Output
    • How do I import a text file?
    • How Do I Process a Binary File?
    • How do I export a csv file?
    • How do I get the content of a URL on a web server into Revolution?
    • How do I rename the headers on a text file?
    • Uploading a file using FTP
  • The LiveCode Message Path 2
    • How to call a function or command in another object?
    • How to send messages to an object using the send command
  • Custom Properties 3
    • How do I save custom properties in a standalone application?
    • How do I define my own properties for an object?
    • Grouping custom properties in a custompropertyset
  • LiveCode tips 18
    • How to communicate with other applications using sockets
    • Opening a Stack from the Server
    • How do I Locate Scripts or Custom Properties in my Project?
    • How to relayer grouped controls
    • Setting toolTip and toolTipDelay
    • How do I get the path to common folders on my computer?
    • How can I get the path to the folder a stack file resides in?
    • Message box tips and tricks
    • What Are The Alternatives To Using Global Variables?
    • How to use date and time in Rev
    • How to create simple lists in LiveCode
    • How to create PDFs using LiveCode
    • How do I Create an HTML E-Mail?
    • How do I Attach a File to an E-Mail?
    • Dropping System Folders on Fields
    • How to Quickly Edit a Palette Stack in the IDE
    • Visual Basic-to-revTalk cheat sheet
    • How to create an application that opens when you drag a file onto it
  • LiveCode Arrays 9
    • How do I display an array in a table field?
    • How do I convert tab delimited data into an array?
    • How do I sort an array?
    • How do I add keys to or delete keys from an array?
    • How do I rename a key in an array?
    • How do I store an array in a text file and then retrieve it again?
    • How do I Search an Array?
    • How do I Display an Array in Human Readable Form?
    • How do I Store an Array Variable Inside of Another Array Variable?
  • Using Behaviors 3
    • How To Assign A Behavior
    • How to Override a Behavior
    • How To Create Field Placeholder Text Using Behaviors
  • LiveCode and Databases 5
    • How do I Create and set up a Database?
    • Converting a Database Cursor to a Data Grid Array
    • Connecting to a MySQL database
    • How to connect Database using ODBC
    • How to create and use an SQLite database
  • Creating an 8-puzzle game 3
    • How do I Create an 8-Puzzle Game?
    • How do I Tell the Computer to Solve the 8-Puzzle Game?
    • How do I Tell the Computer to Solve the 8-Puzzle Game Using A*?
  • Groups 0
  • Using Graphics 3
    • How do I Create Animated Overlays?
    • How do I add Motion to Animated Overlays?
    • How to create a scrolling group using the improved graphics architecture
  • Using Images 9
    • How to Create a Thumbnail Image
    • Vision: How do I Threshold an Image?
    • Vision: How do I Blur an Image?
    • Vision: How do I Edge Detect an Image?
    • How to proportionally resize an image
    • Vision: How do I Convert a Color Image to Grayscale?
    • How do you embed an image in a stack so a path reference is not needed?
    • Screenshot with Effects
    • How do you display an image by dragging it on to a stack?
  • LiveCode Plugins and Externals 5
    • How To Install 3rd Party Externals For Use in the IDE and Standalone Builder
    • How To Install a 3rd Party Plugin In the Revolution IDE
    • How to safely attach an external to your stack
    • Linking an OSX external bundle with a .dylib library
    • How to install custom user plugins
  • LiveCode revLets and the Web plugin 7
    • How to build a revlet
    • How do I communicate with the browser from a plugin?
    • How do I determine which permissions a revlet has?
    • How do I create a web-based revlet that references assets such as videos?
    • How do I pass data from a webpage to a plugin?
    • How do I Pass Variable Data from a Webpage to a Plugin?
    • How to build a revLet without a security prompt
  • Using dialogs 7
    • How do I Create a Color Picker Swatch?
    • How can I restrict an answer file dialog to just applications?
    • How Can I Pass Data To and Get Data From a Dialog Window?
    • How do I Create a Modal Dialog?
    • How to control where the answer file/folder dialog starts
    • How do I use the Project Browser?
    • How do I create a scalable UI using graphics?

Last Updated

Oct 24, 2009

Download Lesson PDF

Other Resources

  • Getting Started with LiveCode

  • Get Up and Running with LiveCode
  • Getting Started with LiveCode Development
  • LiveCode Concepts

  • Features, concepts and aspects of LiveCode
  • LiveCode Lessons

  • How To - Step-By-Step Guides To Tasks In LiveCode
  • How To - LiveCode Server Tasks
  • How To - LiveCode Mobile Tasks
  • How To - LiveCode Sample Scripts
  • How to - LiveCode Marketplace Products
  • How to Purchase and License LiveCode
  • Tutorials

  • Creating a Video Library Application
  • Data Grid

  • LiveCode Data Grid
  • Data Grid Tips & Tricks
  • Converting the Stock Program

Comments

5 for this lesson

  • Prev: How to create a scrolling group using the improved graphics architecture
  • Next: Vision: How do I Threshold an Image?

How to Create a Thumbnail Image

Creating a 32 x 32 pixel thumbnail image of a control

Select the thumbnail source

In this case I want to create a thumbnail image of a knob control on my stack.
The source will be the id of the knob group.

Select an image name

Here I want to pick a unique name for the new image. I'm going to call it "tmp" followed by a number.
I want to make sure there's no image by that name already, so I'm going to cycle through numbers until I find an available slot.

put "tmp 1" into tImageName
repeat while there is an image tImageName
     add 1 to word 2 of tImageName
end repeat

Create a new image

create image tImageName
set the visible of image tImageName to true
set the resizequality of image tImageName to "best"

Take a snapshot of the source control

This is what does the work of making the image. Here pControlID is the id of the control I want to make a thumbnail from (the knob control group).

export snapshot from control id pControlID to image tImageName as PNG

Size the image to 32 x 32 pixels

Obviously you can use any size you want, but here I want a 32 x 32 pixel thumbnail image.

set the width of image tImageName to 32
set the height of image tImageName to 32

Make the new image size permanent

This step is somewhat nonintuitive. If you don't do this step then the width and height you just set will not stick, and the image will stay the original size. The next time you open the image it will spring back from the thumbnail size. You don't want this. Setting the imagedata makes the new size for the thumbnail permanent.

set the imagedata of image tImageName to the imagedata of image tImageName

Put the thumbnail in the clipboard for pasting

We don't really need to do this, but we might as well.

copy image tImageName

So here's a complete handler, ready to go. Pass the id of the control to the CreateThumbnail handler.

on mouseUp
    CreateThumbnail the id of group "knob"
end mouseUp

on CreateThumbnail pControlID
    local tImageName
    
    -- pick a unique name for the image
    put "tmp 1" into tImageName
    repeat while there is an image tImageName
        add 1 to word 2 of tImageName
    end repeat
    -- create an image for the thumbnail
    create image tImageName
    set the visible of image tImageName to true
    set the resizequality of image tImageName to "best"
    export snapshot from control id pControlID to image tImageName as PNG
    set the width of image tImageName to 32
    set the height of image tImageName to 32
    -- make the new size permanent
    set the imagedata of image tImageName to the imagedata of image tImageName
    -- put in the clipboard for pasting
    copy image tImageName
end CreateThumbnail

  • Prev: How to create a scrolling group using the improved graphics architecture
  • Next: Vision: How do I Threshold an Image?

Comments (5)

Jessamy Goddard Friday Aug 17 at 11:47 AM

Hi RunRev team,

I am trying to make a scrolling page of thumbnails that the user can press and get to a large image.

I am stuck on making the scrolling page of thumbnails.
I have tried all sorts - to no avail.

Please could you help?

Thankyou,
Jessamy

Hanson Schmidt-Cornelius Monday Aug 20 at 02:15 AM

Hi Jessamy,

it depends on what platforms you want to include.
If you are intending to use the mobile devices, then I recommend looking at native controls. In particular have a look at 'mobileControlCreate "scroller"' in the dictionary. You should also look at mobileControlSet, mobileControlGet, mobileControlDo and mobileControlDelete. The following lesson shows you how to use native controls for text manipulation: http://lessons.runrev.com/s/lessons/m/4069/l/29112-how-do-i-use-native-text-controls-on-ios

If you are implementing the scrolling functionality on other or additional platforms, then I would have a look at the data grid: http://lessons.runrev.com/m/datagrid

Also don't forget to have a look around our forums and post there for more information: http://forums.runrev.com/

Kind Regards,

Hanson

Jessamy Goddard Wednesday Aug 22 at 09:17 AM

Dear Hanson,
Thankyou for the help.
I actually made the scrolling thumbnails before you sent the reply.
I am now trying to make arrays of images.
If you can point me to a relevant example I would really appreciate it.

Thankyou again.
Jessamy.

Hanson Schmidt-Cornelius Monday Aug 27 at 03:45 AM

Hi Jessamy,

there is no explicit lesson that describes how to create an array of images. There is one lesson that creates an 8-Puzzle board of buttons. You could have a look at that and expand it to the array dimensions you require. The buttons would be the thumbnails you want to position.
http://lessons.runrev.com/s/lessons/m/4071/l/15454
Have a look at the "createBoard" command.

Kind Regards,

Hanson

Jessamy Goddard Thursday Aug 30 at 02:21 PM

Thankyou Hanson. That was really helpful.
I am making good progress.!!
I will get back to you next time I get stuck.
You have been such a help.
All the best,
Jessamy.

Add your comment

E-Mail me when someone replies to this comment
Brought to you by RunRev Ltd, Registered in Scotland, No. SC200728