Page 1 of 1

Display distant image in a graphic object?

Posted: Thu Mar 12, 2020 9:46 am
by Zax
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.

Re: Display distant image in a graphic object?

Posted: Thu Mar 12, 2020 11:09 am
by richmond62
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?"

Re: Display distant image in a graphic object?

Posted: Thu Mar 12, 2020 11:27 am
by [-hh]
@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).

Re: Display distant image in a graphic object?

Posted: Thu Mar 12, 2020 12:12 pm
by richmond62
[-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.

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

Posted: Thu Mar 12, 2020 3:44 pm
by Zax
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.

Re: Display distant image in a graphic object?

Posted: Thu Mar 12, 2020 6:40 pm
by richmond62
That is a clever way round that one. 8)