Scaling an image to fit the group dimensions

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
rleiman
Posts: 56
Joined: Fri Dec 14, 2012 11:28 am
Contact:

Scaling an image to fit the group dimensions

Post by rleiman » Sun Jan 06, 2013 4:10 pm

Hi Everyone,

Can you show me the coding needed to scale an image to fit the dimensions of a group?

I'm not concerned with aspect ratio but would like the image to fill the entire space of the group.

Thanks.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Scaling an image to fit the group dimensions

Post by dunbarx » Sun Jan 06, 2013 5:27 pm

Sure.

set the rect of image "yourImage" to the rect of group "yourGroup"

Craig Newman

rleiman
Posts: 56
Joined: Fri Dec 14, 2012 11:28 am
Contact:

Re: Scaling an image to fit the group dimensions

Post by rleiman » Sun Jan 06, 2013 5:52 pm

Hi Carig,

I tried it but the image is not filling the entire group.

It fills the width but not the height.

I used this coding:

Code: Select all

on preOpenCard
   put screenrect() into theScreenSize
   
   set the width of group "big ben group" to word 1 of item 3 of the field "theScreenSize" 
   set the height of group "big ben group" to word 1 of item 4 of the field "theScreenSize" 
   set the rect of image "big-ben.png" to the rect of group "big ben group"
end preOpenCard

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Scaling an image to fit the group dimensions

Post by Dixie » Sun Jan 06, 2013 6:08 pm

set the margins of the image and the group to 0

Dixie

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Scaling an image to fit the group dimensions

Post by dunbarx » Sun Jan 06, 2013 6:46 pm

Aha.

Dixie's point may be your problem. Newly created objects (other than fields) have default margins set to four pixels. This may, depending on the construction of your group, cause the edges of the two objects to visually misalign. On the other hand, again depending on the group, you may use this property to your advantage, the other method being that you control the image rect itself.

Craig Newman

rleiman
Posts: 56
Joined: Fri Dec 14, 2012 11:28 am
Contact:

Re: Scaling an image to fit the group dimensions

Post by rleiman » Sun Jan 06, 2013 6:51 pm

Thanks everyone for the helpful replies. :D

Post Reply