I ran into the same problem when I was playing around with a way to make a picture viewer. I made a function that would get the properties of the image and then adjust the image as it was displayed. This is very simple code and only looks for portrait or landscape pictures and adjusts the image accordingly. You should be able to modify appropriately to adjust for the correct ration of your image.
In making this function I wanted to make sure that I could view pictures that were taken and larger than the project, but ensure that they were displayed withing the confines of the project. You will also notice that a second image is referenced ("Image2"). This is a border around the picture and acts like a frame so I had to resize accordingly.
Anywho, here is the function:
Code:
function GetImage(landscape,portrait)
image = pic_table[ctr];
image_info = Image.GetFileInfo(image);
if (image_info.Width > image_info.Height) then
iwidth = landscape
else
iwidth = portrait
end
ratio = (image_info.Width / iwidth);
iheight = (image_info.Height / ratio);
Image.SetVisible ("Image1", false);
Image.SetVisible ("Image2", false);
Image.SetSize("Image2", (iwidth + 20), (iheight + 20));
Image.SetSize("Image1", iwidth, iheight);
Image.Load("Image1", image);
Image.SetVisible ("Image2", true);
Image.SetVisible ("Image1", true);
end
And here is an example of how I would use it.
Code:
ssfolder = Dialog.FolderBrowse("Select a folder that contains pictures.", _DesktopFolder);
pic_table = File.Find(ssfolder, "*.jpg", false, false, nil);
pic_count = Table.Count(pic_table);
ctr = 1;
GetImage(500,375)
Image.SetVisible("Image1", true);
Image.SetVisible("Image2", true);
I hope that helps
Tigg