[SOLVED] save image button

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
rijaaall
Posts: 17
Joined: Tue Jun 12, 2012 10:49 am

[SOLVED] save image button

Post by rijaaall » Tue Jun 12, 2012 12:54 pm

can anyone help me to make a button which is used to save image that have uploaded and processed?
to .pgn
fast respons. thanks :(
Last edited by rijaaall on Wed Jun 13, 2012 1:22 am, edited 1 time in total.

Klaus
Posts: 14197
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: save image button

Post by Klaus » Tue Jun 12, 2012 1:48 pm

Hi rijaaali,

ok, I think you can create a button, but I will help you with the script, of course 8)
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! :D





Best


Klaus

rijaaall
Posts: 17
Joined: Tue Jun 12, 2012 10:49 am

Re: save image button

Post by rijaaall » Tue Jun 12, 2012 5:32 pm

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 :D

hhmmm.. but, can the "file/to your/file.png" change into file preference like choosing place where the user want to export?

Klaus
Posts: 14197
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: save image button

Post by Klaus » Tue Jun 12, 2012 6:06 pm

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/

rijaaall
Posts: 17
Joined: Tue Jun 12, 2012 10:49 am

Re: save image button

Post by rijaaall » Tue Jun 12, 2012 6:18 pm

thank you very much mr. Klaus :)
but, if there any more short script? :D 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? :mrgreen:

Klaus
Posts: 14197
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: save image button

Post by Klaus » Tue Jun 12, 2012 6:35 pm

Hi rijaaali,

in LiveCode you can start counting from the end :D

Char -1 = the last char
Char -4 = the 4th last char...? OK, example :D

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

rijaaall
Posts: 17
Joined: Tue Jun 12, 2012 10:49 am

Re: save image button

Post by rijaaall » Tue Jun 12, 2012 8:05 pm

hello mr.klaus..

oooouw i see. i know what you mean now :D
thank you very much

i have upload it on 4shared.

www*4shared*com/file/hHncrGlU/threshold*html
change (*) with (.)
try this
Last edited by rijaaall on Wed Jun 13, 2012 1:19 am, edited 1 time in total.

rijaaall
Posts: 17
Joined: Tue Jun 12, 2012 10:49 am

Re: save image button

Post by rijaaall » Tue Jun 12, 2012 8:11 pm

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.

Klaus
Posts: 14197
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: save image button

Post by Klaus » Tue Jun 12, 2012 8:12 pm

You should Sign Up or Login to download this file
Hm, no thanks...

rijaaall
Posts: 17
Joined: Tue Jun 12, 2012 10:49 am

Re: save image button

Post by rijaaall » Tue Jun 12, 2012 8:19 pm

Klaus wrote:
You should Sign Up or Login to download this file
Hm, no thanks...
ok thanks :cry:

Post Reply