import paint

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

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

import paint

Post by robm80 » Thu Jul 17, 2014 12:37 pm

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

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: import paint

Post by magice » Thu Jul 17, 2014 12:52 pm

Look up Filename in the dictionary

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

Re: import paint

Post by Klaus » Thu Jul 17, 2014 12:57 pm

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

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

Re: import paint

Post by Klaus » Thu Jul 17, 2014 12:59 pm

magice wrote:Look up Filename in the dictionary
Nice, but has nothing to do with the question! 8)

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: import paint

Post by magice » Thu Jul 17, 2014 1:02 pm

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.

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: import paint

Post by robm80 » Thu Jul 17, 2014 6:49 pm

Why this does not work ?
sshot-04.jpg
nor his one:
sshot-05.jpg
Thanks,Rob

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

Re: import paint

Post by Klaus » Thu Jul 17, 2014 6:53 pm

"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?

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: import paint

Post by robm80 » Thu Jul 17, 2014 9:13 pm

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

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

Re: import paint

Post by Klaus » Thu Jul 17, 2014 10:07 pm

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

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: import paint

Post by robm80 » Fri Jul 18, 2014 4:28 am

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?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: import paint

Post by Simon » Fri Jul 18, 2014 6:24 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: import paint

Post by robm80 » Fri Jul 18, 2014 7:32 am

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.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: import paint

Post by Simon » Fri Jul 18, 2014 7:51 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: import paint

Post by robm80 » Fri Jul 18, 2014 9:16 am

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

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

Re: import paint

Post by Klaus » Fri Jul 18, 2014 12:15 pm

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

Post Reply