4D An P3005 ViSi Adding Image and Video Objects
4D An P3005 ViSi Adding Image and Video Objects
4D An P3005 ViSi Adding Image and Video Objects
4D SYSTEMS
4D-AN-P3005
Description
Content
This Application Note shows how to add image and video objects in ViSi.
Before getting started, the following are required:
Description ............................................................................................. 2
Content .................................................................................................. 2
Application Overview .............................................................................. 3
Launch Workshop 4................................................................................. 3
Create a New Project .............................................................................. 4
Create a New Project ....................................................................... 4
Select ViSi ........................................................................................ 5
Design the Project ................................................................................... 5
Program Skeleton ............................................................................ 5
Uncomment the Necessary Parts
10
Video Frames
11
11
A Simple Example
13
2013 4D Systems
Page 2 of 15
www.4dsystems.com.au
4D SYSTEMS
Proprietary Information ........................................................................ 15
4D-AN-P3005
Application Overview
Launch Workshop 4
There is a shortcut for Workshop 4 on the desktop.
2013 4D Systems
Page 3 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P3005
These options update the main window with the selection of the screen.
Select your screen. The screen used in this example is the uLCD-32WPTU
(Portrait orientation).
Page 4 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P3005
Select ViSi
Program Skeleton
Observe that in the main function, the lines are commented out. Also,
instructions are given to uncomment a line if needed. In this application
Page 5 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P3005
note, most of the existing lines are needed. Remove the block comment
symbols shown below.
2013 4D Systems
Page 6 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P3005
Once the Image icon is selected, click on the WYSIWYG screen to place it. A
standard Open window appears. Browse for the desired file and click
Open. The WYSIWYG screen is updated.
It requires two files fname1 and fname2, the .dat file and .gci file,
respectively. These files are created by Workshop. The GCI file contains all
the graphics for the images and/or videos created by Workshop. The DAT
file contains one line, for each image or video, that names the object and
gives its starting offset within the GCI and its initial X/Y position.
C
Image Object
Create an Image Object in the WYSIWYG Screen
Go to the Widgets menu, select the System/Media pane, and click on the
Image icon.
2013 4D Systems
The user can drag the object to any desired location in the WYSIWYG
screen. It is also possible to resize the image by dragging the borders.
Further editing of other properties can be done using the Object Inspector.
The user may want to limit the image size (length and width) so as to give
room for a video object later on in this application note.
Page 7 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P3005
Go to the code area and place the cursor just after the handle assignment
statement (line 32 in this example).
A new line for the image object is generated, along with a comment. The
command
Having selected the image object, go to the Object Inspector and click on
the Paste Code button.
img_Show(hndl,iImage1)
simply displays the image that has been created. Note that iImage1 is an
image index for the object created.
Save the Program for Compilation and Downloading
Now we make a quick test if the simple program works. Save the program
with the desired file name first, and then compile and download it. The
program in this example is saved as VIDIMAGEtutorial.
2013 4D Systems
Page 8 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P3005
Workshop copies the GCI files to the SD card and downloads the program
to the display module. The message box will look like as shown below after
a successful download.
After making sure that the device is detected, insert the SD card into the
SD card slot (if using a SD to SD card adaptor) or USB port (if using a SD
to USB adaptor) of your PC. Format the SD card if necessary.
Now go to the Home menu and click on the Comp nLoad button.
C
Remove the SD card and insert it into the SD card slot of the display
module. The program will now run. The image should be shown on the
display module screen as configured in the WYSIWYG screen. Below is the
code at this point, with the unnecessary lines excluded.
The Copy Confirmation window appears. The user will be prompted to
choose the drive. Choose the correct drive by clicking on the drop down
arrow. Then click on OK.
2013 4D Systems
Page 9 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P3005
#platform "uLCD-32WPTU"
Video Object
#inherit "4DGL_16bitColours.fnc"
Go to the Widgets menu, select the System/Media pane, and click on the
Video icon.
#inherit "VisualConst.inc"
#inherit "VIDIMAGEtutorialConst.inc"
func main()
putstr("Mounting...\n");
if (!(disk:=file_Mount()))
while(!(disk :=file_Mount()))
putstr("Drive not mounted...");
pause(200);
gfx_Cls();
pause(200);
wend
endif
gfx_TransparentColour(0x0020);
gfx_Transparency(ON);
gfx_Cls();
hndl := file_LoadImageControl("VIDIMA~1.dat",
"VIDIMA~1.gci", 1);
Once the Video icon is selected, click on the WYSIWYG screen to place it. A
standard Open window appears and displays the files that can be opened.
Browse for the desired file and click Open. The WYSIWYG screen is
updated.
2013 4D Systems
Page 10 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P3005
The user can drag the object to any desired location in the WYSIWYG
screen. It is also possible to resize the object by dragging the borders.
Further editing of other properties can be done using the Object Inspector.
Video Frames
It is possible for the user to know the number frames inside a video. In the
Object Inspector click on the symbol
beside Frames.
The video added in this application note has the frame properties shown
above. Total number of frames is 605 from 0 (First) to 604 (Last). The
user has the option of choosing what frames to include in the GCI file by
changing the First and Last frame properties. For example,
2013 4D Systems
The user can view the actual frames by clicking on the Video property line
Go to the code area and place the cursor after the handle assignment
statement (line 37 after the img_Show() command in this example).
Page 11 of 15
www.4dsystems.com.au
4D SYSTEMS
Having selected the video object, go to the Object Inspector and click on
the Paste Code button.
4D-AN-P3005
A new block for the video object is generated, along with a comment. The
command
img_SetWord(hndl, iVideo1, IMAGE_INDEX, frame)
is used to set which frame of the movie is to be displayed. The user can
replace the fourth argument, frame, with a frame value. For instance, set
the program to display frame 0 of the object Video1 by writing the
statement
img_SetWord(hndl, iVideo1, IMAGE_INDEX, 0)
After having set the frame to be shown, display the frame with the
command
img_Show(hndl,iVideo1)
To display three frames in succession, the user can use the code below.
2013 4D Systems
Page 12 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P3005
Or
Note that for the fourth argument, frame, the range of possible values
depends on how many frames the video object has - 0 to 604 for the video
used in this application note. If the user is doing pure codes in the Designer
environment, is also possible to get the number of frames by using the
function
A Simple Example
To play an entire video, the user can use a loop with an incrementing
counter. To illustrate:
for(frame := 0; frame <= 604; frame ++)
img_SetWord(hndl, iVideo1, IMAGE_INDEX, frame) ;
img_Show(hndl,iVideo1) ;
pause(33);
next
2013 4D Systems
Page 13 of 15
www.4dsystems.com.au
4D SYSTEMS
Near the bottom of the drop down menu, you can find the Samples
button, click on it.
4D-AN-P3005
Select the file VIDIMAGE then click on Open.
2013 4D Systems
Page 14 of 15
www.4dsystems.com.au
4D SYSTEMS
4D-AN-P3005
Proprietary Information
The information contained in this document is the property of 4D Systems Pty. Ltd. and may be the subject of patents pending or granted, and must not be
copied or disclosed without prior written permission.
4D Systems endeavours to ensure that the information in this document is correct and fairly stated but does not accept liability for any error or omission. The
development of 4D Systems products and services is continuous and published information may not be up to date. It is important to check the current
position with 4D Systems.
All trademarks belong to their respective owners and are recognised and acknowledged.
2013 4D Systems
Page 15 of 15
www.4dsystems.com.au