Page 1 of 2

import paint

Posted: Thu Jul 17, 2014 12:37 pm
by robm80
How to refer to an imported picture. Paint nor image will do.

Code: Select all

import paint from file "c:\thumbnails\foo.jpg"
put name of ?????????? into tVar
thanks,Rob

Re: import paint

Posted: Thu Jul 17, 2014 12:52 pm
by magice
Look up Filename in the dictionary

Re: import paint

Posted: Thu Jul 17, 2014 12:57 pm
by Klaus
LC will creeate a new image objct and put the file into that new image!
So you can refer to it as "last image":

Code: Select all

...
## Livecode ALWAYS uses the UNIX slash as a path delimiter:
import paint from file "c:/thumbnails/foo.jpg"

## This will put this into tVar: image "Image"
put the name of last img into tVar

## Maybe you want ot give a new name FIRST and then put that into a variabel:
set the name of last img to "the newly imported image"
put "the newly imported image" into tVar
...
Will of course also work with shorter names :D


Best

Klaus

Re: import paint

Posted: Thu Jul 17, 2014 12:59 pm
by Klaus
magice wrote:Look up Filename in the dictionary
Nice, but has nothing to do with the question! 8)

Re: import paint

Posted: Thu Jul 17, 2014 1:02 pm
by magice
Klaus wrote:
magice wrote:Look up Filename in the dictionary
Nice, but has nothing to do with the question! 8)
My mistake, I misunderstood the question. That's what I get foe pre-coffee thread reading.

Re: import paint

Posted: Thu Jul 17, 2014 6:49 pm
by robm80
Why this does not work ?
sshot-04.jpg
nor his one:
sshot-05.jpg
Thanks,Rob

Re: import paint

Posted: Thu Jul 17, 2014 6:53 pm
by Klaus
"Does not work" is no valid error description! 8)

Did you get an error? If yes, what does say?
Is the button "pict" on the same card as the new image?

Re: import paint

Posted: Thu Jul 17, 2014 9:13 pm
by robm80
Did you get an error? If yes, what does say?
Is the button "pict" on the same card as the new image?
No errormessage.
No, button pict is on the mainstack, the image on a substack "foto", because the image
is so large that it is placed over the whole stack.
I'll try to put them together, using lockscreen to avoid seeing this large picture.

Or I an resize the pictures in the file, from where they are importedIO

Re: import paint

Posted: Thu Jul 17, 2014 10:07 pm
by Klaus
robm80 wrote:Or I an resize the pictures in the file, from where they are importedIO
That is of course the very best solution! :D

Re: import paint

Posted: Fri Jul 18, 2014 4:28 am
by robm80
With this:
on mouseUp
delete last image
put "c:/newthumbnails/" into tStam
import paint from file tStam& fld "filefrom"
set the rect of last image to the rect of button "pict"
end mouseUp
The image is placed OVER the button "pict", so it is not the icon of and likewise "set the icon of button "pict" to image "foo" is removed from the script.
Why no icon?

Re: import paint

Posted: Fri Jul 18, 2014 6:24 am
by Simon
Ok I'm not following this thread.
Rob are you trying to set the icon of a button to an image selected by the user? If so;
With a new stack with 1 image (you should hide it) and 2 buttons put this into the second button;

Code: Select all

on mouseUp
   set the lockLocation of btn 1 to true
   answer file "Dude pick a picture" with type "JPEG Images|jpg|JPEG"
   set the filename of img 1 to it
   set the icon of btn 1 to the id of img 1
end mouseUp
What is paint used for?
There is probably a cleaner way to do this.

Simon

Re: import paint

Posted: Fri Jul 18, 2014 7:32 am
by robm80

Code: Select all

There is probably a cleaner way to do this.
There certainly is, but with this script I get all I want.
"Import paint" I found in the dictionary: it gets a picture from any directory and places it over the button.
The next time I need a new picture I delete the last one with this script:

Code: Select all

on mouseUp
   delete last image
   put the filename of this stack into tVar
   put char 1 to 12 of tVar & "thumbnails/" into tStam  ------- now any user who has a directory "thumbnails" placed in the stack's directory may use this script
   import paint from file tStam& fld "filefrom"
   set the rect of last image to the rect of button "pict"
 end mouseUp
As you understand, fld "filefrom" is the field where I type the name of the picture.

Re: import paint

Posted: Fri Jul 18, 2014 7:51 am
by Simon
Wow really confused now
but with this script I get all I want.
Which script?
Is everything ok now? Problem solved? Question answered? Am I still missing the point?
Communication can be so very difficult. Apologies if I got it all wrong.

Simon

Re: import paint

Posted: Fri Jul 18, 2014 9:16 am
by robm80
Which script?
Is everything ok now? Problem solved? Question answered? Am I still missing the point?
Hi Simon,
I don't understand what you don't understand.

Which script: the script in de last posting. As I said, I now can import a picture from everywhere.
OK: so far, yes; the stack I try to build is has just began.
Problem solved: so far, yes.
Question answered? always by Klaus; so far, yes.
Am I still missing the point?: so far, yes.

Have a good day
Rob

Re: import paint

Posted: Fri Jul 18, 2014 12:15 pm
by Klaus
robm80 wrote:With this:

Code: Select all

on mouseUp
   delete last image
   put "c:/newthumbnails/" into tStam

   ## ALWAYS use parens when concatenating object- and filenames!
   import paint from file (tStam & fld "filefrom")
   set the rect of last image to the rect of button "pict"
end mouseUp
The image is placed OVER the button "pict", so it is not the icon...
What do you exspect? When you create a new object, that new object will ALWAYS have the highest layer (= on top of everything).
And simply importing an image will of course NOT make it a buttons ICON.
... and likewise "set the icon of button "pict" to image "foo" is removed from the script.
??? I did not remove anything!
Why no icon?
Because that line is missing from your script 8)

Rob, did you work through the Scripting conferences to get the very basics of Livecode? You really should do!
http://www.hyperactivesw.com/revscriptc ... ences.html