Display distant image in a graphic object?

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
Zax
Posts: 469
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Display distant image in a graphic object?

Post by Zax » Thu Mar 12, 2020 9:46 am

Hello,

Is there a way to display a distant image (something like https://livecode.com/wp-content/uploads ... 8x1024.jpg) in a graphic object?
I know this can easily be done with an image object.

To display local dropped image on a Graphic object, I use this script:

Code: Select all

on dragEnter
   set the dragAction to "copy"
end dragEnter

on dragDrop
   lock screen
   import paint from file the dragData["files"]
   set the backGroundPattern of me to (the id of last image)
   delete last image
end dragDrop
Thanks.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Display distant image in a graphic object?

Post by richmond62 » Thu Mar 12, 2020 11:09 am

I have just been fiddling around with this:

Code: Select all

on mouseUp
   set the imageSource of the backGroundPattern of grc "rr" to "https://livecode.com/wp-content/uploads/2018/04/multiplatform-2-1018x1024.jpg"
end mouseUp
and this:

Code: Select all

on mouseUp
   set the imageData of the backGroundPattern of grc "rr" to "https://livecode.com/wp-content/uploads/2018/04/multiplatform-2-1018x1024.jpg"
end mouseUp
and this

Code: Select all

on mouseUp
   set the backGroundPattern of grc "rr" to the imageData of img "qq"
end mouseUp
[ where img "qq" contains that picture ]

which prove quite obviously that I haven't a clue. 8)

Of course, the painful question is, "What particular advantage would there be displaying a distant image inside a graphic object
over displaying it inside an image?"

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Display distant image in a graphic object?

Post by [-hh] » Thu Mar 12, 2020 11:27 am

@richmond62.
"What particular advantage would there be displaying a distant image inside a graphic object
over displaying it inside an image?"
The graphic clips the image. Try that with an oval graphic and an appropriately scaled image.

@zax.
Your question is (implicitly) twofold:
1. Display: As you know how to do this with images use that:
Put the local or extern data into ONE image "temp" and set the backpattern to the image's id. There is NO advantage of using import paint to that method.

2. DragAndDrop: As long as the url of your drag object is a "proper" image url, there will be no problem. When using an image collection like google images you have to extract such a proper url (may be a dataURL) from the dragData.

Test how dragAndDrop of images works for example in http://hyperhh.de/html5/html5Player.html :
Select "ImgView", then "Import Local" and dragAndDrop from a different browser window containing images (these are "local" because they ARE already displayed locally). Or select "ImgURL".
If you drag a thumbnail from the other browser window it remains a thumbnail. Click on the thumbnail and then drag the enlarged view to have the full sized image (which may then be scaled by LC).
shiftLock happens

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Display distant image in a graphic object?

Post by richmond62 » Thu Mar 12, 2020 12:12 pm

[-hh] wrote:
Thu Mar 12, 2020 11:27 am
@richmond62.
"What particular advantage would there be displaying a distant image inside a graphic object
over displaying it inside an image?"
The graphic clips the image. Try that with an oval graphic and an appropriately scaled image.
That's why I wouldn't bother, and cannot see what advantage the OP may gain from this.

Zax
Posts: 469
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

[SOLVED] Re: Display distant image in a graphic object?

Post by Zax » Thu Mar 12, 2020 3:44 pm

Thank you for your answers.

This works fine :)

Code: Select all

put "https://livecode.com/wp-content/uploads/2018/04/multiplatform-2-1018x1024.jpg" into tUrl
set the filename of image "ImgTemp" to tUrl -- hidden "Image" object
set the backgroundPattern of graphic "GraphicTest" to (the id of image "ImgTemp")
As the final goal is to test online backgrounds, I prefer to use a graphic object to clip (and possibly repeat) the distant image.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Display distant image in a graphic object?

Post by richmond62 » Thu Mar 12, 2020 6:40 pm

That is a clever way round that one. 8)

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”