Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
ActiveX Web controler
XTinyadoDB xtra
playheadSlider
All Purpose Status Bar
Countdown Timer
Interactivity by Design
VbScript Xtra
Opening and closing a CD-door behaviour
PDF Publishing in Multimedia Projects
Wait for SWA Member finishes Playing(sprite as reference)
 

 

 

Behavior Rescale Image

Added on 6/12/2000

 

Compatibilities:
D8 Mac PC Script Shockwave

This item has not yet been rated

Author: DaveMennenoh

Rescales a bitmap cast member to a given max width or max height while preserving the original aspect ratio of the image. This means that normally one of the dimensions of the new bitmap will match one of the max dimensions while the other dimension will be equal to or smaller than the other max dimension. The new image replaces the original.

--rescale (member , max width, max height)

--Rescales a bitmap cast member to a given max width or max height
--while preserving the original aspect ratio of the image.
--This means that normally one of the dimensions of the new
--bitmap will match one of the max dimensions while the other
--dimension will be equal to or smaller than the other max dimension.
--The new image replaces the original.

--membRef - member reference of original bitmap to rescale.
--maxW - maximum width of the rescaled image.
--maxH - maximum height of the rescaled image.
on rescale membRef,maxW,maxH
  wide=membRef.width
  high=membRef.height
  repeat while wide>maxW or high>maxH
    if wide>maxW then
      scaler=maxW/float(wide)
      wide=wide*scaler
      high=high*scaler
      nI=image(wide,high,32)
      nI.copyPixels(membRef.image,nI.rect,membRef.rect)
      membRef.erase()
      k=new(#bitmap,membRef)
      k.image=nI
    end if  
    wide=membRef.width
    high=membRef.height
    if high>maxH then
      scaler=maxH/float(high)
      wide=wide*scaler
      high=high*scaler
      nI=image(wide,high,32)
      nI.copyPixels(membRef.image,nI.rect,membRef.rect)
      membRef.erase()
      k=new(#bitmap,membRef)
      k.image=nI
    end if
    wide=membRef.width
    high=membRef.height
  end repeat
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail