PDA

View Full Version : Function: Resize an Image to Fit your Project Window



Adam
06-03-2004, 11:55 AM
This function will make an Image Object resize to the size of your project. The function accepts 2 arguments: The first argument is the name of the image object that you would like to resize and the second is a string that represents the type of window you are using. The valid arguments are:


Standard (default)
Bordered
Flat


Here is the function code:



function ResizeImageToWindow (ObjectName,Titled)
-- Titled can equal:
-- Standard (default)
-- Bordered
-- Flat

-- Get the size of that Image
size = Window.GetSize(Application.GetWndHandle());
-- If the window is Flat
if Titled == "Flat" then
Image.SetSize(ObjectName, size.Width, size.Height);

-- If the window is Bordered
elseif Titled == "Bordered" then
Image.SetSize(ObjectName, size.Width - 6, size.Height - 6);

--Titled == "Standard"
else
Image.SetSize(ObjectName, size.Width - 10, size.Height - 36);
end
Image.SetPos(ObjectName, 0, 0);
end


To call this function for an Image Object name "Image1" with the window type as "Flat":



ResizeImageToWindow("Image1","Flat");