Page 1 of 1
[SOLVED] save image button
Posted: Tue Jun 12, 2012 12:54 pm
by rijaaall
can anyone help me to make a button which is used to save image that have uploaded and processed?
to .pgn
fast respons. thanks

Re: save image button
Posted: Tue Jun 12, 2012 1:48 pm
by Klaus
Hi rijaaali,
ok, I think you can create a button, but I will help you with the script, of course
And welcome to the forum!
You can always EXPORT an image from LiveCode to a file on disk:
...
export img "your image here" to file "path/to your/file.png" as PNG
...
Check the dictionary for more info about "export".
fast respons.
Will cost extra!
Best
Klaus
Re: save image button
Posted: Tue Jun 12, 2012 5:32 pm
by rijaaall
Klaus wrote:Hi rijaaali,
...
export img "your image here" to file "path/to your/file.png" as PNG
...
Best
Klaus
waaw its so usefull. thank you master
hhmmm.. but, can the "file/to your/file.png" change into file preference like choosing place where the user want to export?
Re: save image button
Posted: Tue Jun 12, 2012 6:06 pm
by Klaus
Hi rijaaali,
you mean let the user decide where to save the image?
Add this to your image export script:
Code: Select all
...
ASK file "Where to save the image?"
put it into tTargetImageFile
## User cancel:
if tTargetImageFile = empty then
exit mouseup
end if
## Add PNG suffix if necessary:
if char -4 to -1 of tTargetImageFile <> ",png" then
put ".png" after tTargetImageFile
end if
## This is only necessary, if you are on a Mac!
set the filetype to ""
## Now export image to file:
export img "your image here" to file tTargetImageFile as PNG
...
Best
Klaus
P.S.
Check these stacks, great learning resources:
http://www.runrev.com/developers/lesson ... nferences/
Re: save image button
Posted: Tue Jun 12, 2012 6:18 pm
by rijaaall
thank you very much mr. Klaus

but, if there any more short script?

or what is the meaning of "char -4 to -1" ?
for more, may i upload my app ? and would you help me for next step?

Re: save image button
Posted: Tue Jun 12, 2012 6:35 pm
by Klaus
Hi rijaaali,
in LiveCode you can start counting from the end
Char -1 = the last char
Char -4 = the 4th last char...? OK, example
This string, filename of an image:
My beatutiful image.jpg
Char -1 = g
Char -4 = .
Char -4 to -1 of that string above = .jpg
So in my example script I check if the user already added the correct file suffix for PNG files,
which is of course not the case, so I add this to the final filename, to get a valid filepathname.
But I'm afraid you need a certain amount of postings before you can add attachments here to your posting.
So just copy/paste your script(s) here...
Best
Klaus
Re: save image button
Posted: Tue Jun 12, 2012 8:05 pm
by rijaaall
hello mr.klaus..
oooouw i see. i know what you mean now

thank you very much
i have upload it on 4shared.
www*4shared*com/file/hHncrGlU/threshold*html
change (*) with (.)
try this
Re: save image button
Posted: Tue Jun 12, 2012 8:11 pm
by rijaaall
hello mr. klaus..
may u open that?
actually my big problem is, how to fill the white area which has thresholded become a fixie bike with many color.
i mean, when user click in the white area, this app will show a color bucket which is choosen by user. then the white area will change into the color which have been choosen by user.
Re: save image button
Posted: Tue Jun 12, 2012 8:12 pm
by Klaus
You should Sign Up or Login to download this file
Hm, no thanks...
Re: save image button
Posted: Tue Jun 12, 2012 8:19 pm
by rijaaall
Klaus wrote:You should Sign Up or Login to download this file
Hm, no thanks...
ok thanks
