[solved] How to not resize an image in graphic
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
[solved] How to not resize an image in graphic
Hello,
I would like to use an image file on a graphic object to use the image as background (like the "background-image" CSS property).
When I drop an image file on my graphic object, image is automatically resized in order to fit the graphic, and I don't want this. I found how to extand the graphic rect to display the image at full size but that's not what I want.
I would like the image not to be zoomed out nor to be resized. If image is smaller than graphic rect, it would be nice if the image was repeated (one more, like the "background-repeat" CSS property).
Is it possible to do that?
Thanks for your help.
I would like to use an image file on a graphic object to use the image as background (like the "background-image" CSS property).
When I drop an image file on my graphic object, image is automatically resized in order to fit the graphic, and I don't want this. I found how to extand the graphic rect to display the image at full size but that's not what I want.
I would like the image not to be zoomed out nor to be resized. If image is smaller than graphic rect, it would be nice if the image was repeated (one more, like the "background-repeat" CSS property).
Is it possible to do that?
Thanks for your help.
Last edited by Zax on Wed May 24, 2017 9:40 am, edited 1 time in total.
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: [HELP] How to not resize an image in graphic
Repeat is the default behavior. What is your code doing?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: [HELP] How to not resize an image in graphic
Well, in fact, I can't see what is happening with dropped image file smaller than image zone (object) because content (dropped image) is always automatically fitted to its container (the Livecode object), whatever its size, larger or smaller 

-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: [HELP] How to not resize an image in graphic
set the backGroundPattern to grc "XXX" with the id of image "daftPicture"
to guarantee both tiling and no resizing.
The stack is here: https://www.dropbox.com/s/7eeq664wqbrei ... e.zip?dl=0
Re: [HELP] How to not resize an image in graphic
Thank you Richmond.
As I was unable to understand how to use your example with a dropped external image file, so I made image object. This is its script:
Unfortunately, result is the same: dropped image is fitted to the rect of graphic "rr" 
Maybe I missed something.
As I was unable to understand how to use your example with a dropped external image file, so I made image object. This is its script:
Code: Select all
on dragEnter
set the dragAction to "copy"
end dragEnter
on dragDrop
put the dragData["files"] into myImageFile
put url ("binfile:" & myImageFile) into me
set the backGroundPattern of graphic "rr" to (the id of me) -- "rr" is the graphic object I pasted from your sample stack
end dragDrop

Maybe I missed something.
Re: [HELP] How to not resize an image in graphic
OK, based on Richmond sample, the following script works, though maybe it could be simplified:
EDIT: simplified version: only one graphic object, with "dragEnter and "dragDrop" handlers
Code: Select all
on dragEnter
set the dragAction to "copy"
end dragEnter
on dragDrop
lock screen
import paint from file the dragData["files"]
if the result = "" then
set the backGroundPattern of graphic "rr" to (the id of last image)
delete last image
else beep
end dragDrop
Code: Select all
on dragEnter
set the dragAction to "copy"
end dragEnter
on dragDrop
lock screen
import paint from file the dragData["files"]
if the result = "" then
set the backGroundPattern of me to (the id of last image)
delete last image
else beep
end dragDrop
Re: [HELP] How to not resize an image in graphic
If you delete the source image, the graphic won't have a background pattern the next time it is drawn, for example when returning to the card later or on the next startup. I don't know if that matters for your app but just a heads up.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: [solved] How to not resize an image in graphic
In my case, I'm glad the image will be lost but you are right to point this, Jacqueline.