More Exporting and a New Window 2
Add a text graphic as a lable by dragging one from the Tools module to your Export Window. If you hold the command key down when you grab the text graphic from the palette, MPI will keep the draw text tool selected so you can click and type the name of yor label.
Choose the pointer tool and select the label, use the Text Module
to set the font and alignment. Use the colors module
to set the showFill and showPen to None.
Repeat this process and make a quality
popup button to set jpg quality.
We only want the quality button to work when file type is jpeg:
set the disabled of btn id 319 to the short name of me is not "jpeg"
The window is going to be a dialog and we want a default button and a cancel one. (we will set the window style when we have finished the window to make it easier to edit.
Add a round rect Cancel
button, lastly add an round rect Export
button, set its showName
to true using the PI.
The Script for the Cancel
button is easy:
The Export one is a little more complex: the first bit is easy
put the short name of btn id 317 into tFileType
if tFileType = "jpeg" then put the short name of btn id 319 into tquality
ask file "Export image to file:" with ("export image."& tFileType)
if it is "" then exit mouseUp
put it into tfilePath
Now we need to build a command depending on the names of our buttons and do
that, the command will be slightly different if we are exporting to jpeg as we can control quality. The command needs to have quotes round the file path, so we will use the merge function to replace place holders with the values we got from the buttons and to replace the grave accent
char with a quote mark:
if tfileType is not "jpeg"
then do merge("export the pictureData of cd grc `imageDisplay` of cd 1 of wd 1 to [[tFileType]] file `[[tfilepath]]`")
else do merge("export the pictureData of cd grc `imageDisplay` of cd 1 of wd 1 to [[tFileType]] file `[[tfilepath]]` with [[tquality]]")
Before we go any further we should try out our Export
button with the various settings.
When we are happy we can add:
to the end of our button script. We can set the style of the window to dialog or movable either with MPI's control popUp menu (click on a blank area of the card) or on the Windows card of the PI.
I would add a button to the first window Export Image...
with a script to open the export window:
open wd 2