Hi Florian!

I'm looking for a way to scale an image in the cast. This is for an online Shockwave 
puzzle game. The steps involved are

1. Importing an image in Shockwave
2. Resizing the image to 240 x 240
3. Creating the pieces for the puzzle from the imported image
4. Building the game

So scaling the image must be done before the pieces are cropped and put in the score.

This is how I ended up resizing the image:

on sizeImage
  
  myImage = member("userImage").image
  myNewImage = image(240, 240, 16)
  
  x = myImage.rect[3]
  y = myImage.rect[4]
  
  newRect = myNewImage.rect
  
  -- this section croppes a rect from the middle
  if (x < y) then
    newRect = rect(0,0,x,x)
    d = (y - x) / 2
    newRect = rect(0,d,x,x+d)
    
  end if
  
  if (y < x) then
    newRect = rect(0,0,y,y)
    d = (x - y) / 2
    newRect = rect(d,0,y+d,y)

  end if
  
  s = myImage.crop(newRect)
  member("crop_dummy").image = s
  
  myNewImage.copyPixels(member("crop_dummy").image, myNewImage.rect, 
member("crop_dummy").rect)
  member("newImage").image = myNewImage
  sprite(1).member = member("newImage") -- for viewing the result
  
  myImage = void
  myNewImage = void
end

Please let me know if anyone has a better solution doing this. 

Regards,

- Rainer


----- Original Message ----- 
From: "Florian Bogeschdorfer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 30, 2001 10:26 PM
Subject: Re: <lingo-l> Scaling an image with Lingo


> Hi
> 
> If You just want to scale a picture, just set the rect of sprite to your
> desired size, no matter whether you want to enlarge or shrink.
> 
> regards, florian
> 
> Rainer Öhman schrieb:
> > 
> > Hi List!
> > 
> > I need to scale an image to 240 x 240. I can always use the crop() function if the 
>image is bigger. But what steps are involved if the image is smaller?
> > 
> > I can create an image object:
> > 
> >     myNewImage = image(240, 240, 16)
> > 
> > and then use the copyPixels() function to 'pour 'the image into that object. But 
>this distorts the image if it hasn't the same widht and height.
> > 
> > Let's say I've got an image, 200 x 240 pixels. What I'm trying to do is
> > 
> > 1. Resize the image to 240 x 280
> > 2. Crop it to 240 x 240
> > 3. Use the copyPixels() function to assign it to the new image object
> > 4. Set the image property of a cast member to the image object
> > 5. Handing this member to a sprite
> > 
> > - Rainer
> > 
> > [To remove yourself from this list, or to change to digest mode, go to
> > http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
> > email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
> > Lingo-L is for learning and helping with programming Lingo.  Thanks!]
> 
> [To remove yourself from this list, or to change to digest mode, go to
> http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
> email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
> Lingo-L is for learning and helping with programming Lingo.  Thanks!]
> 


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to