Im trying to make a screensaver whit the option to support single and multiple images. this is the code for single images where im trying to make it fit large images to screen but no matter what of these conversion types ive used
Round Rounds a floating point number to an integer
Trunc The integer part of a floating point number
it crashes whit - Incomplete types "Integer" and "Extended"
and then im wondering if its because im yousing delphi 2009 .. maybe i should bye the 2005 if thats still possible.
imageprocent := imageheight * Trunc(form2.Image1.Picture.height) / 100 ; {here it crashes and says Integer and extended - like if it havent been convertet to int above}
imageheightdiff := Trunc(form2.Image1.Picture.Height)- Trunc(screen.Height);
here you don't have to use trunc function as Height is an integer property
imageprocent := imageheight * Trunc(form2.Image1.Picture.height) / 100 ; {here it crashes and says Integer and extended - like if it havent been convertet to int above}
The problem comes from the divide by 100 which gives a non integer result.
You could put form2.Image1.Picture.height/100 in trunc parenthesis, you would get the nearest integer just below.
If you use Round function, you will get the nearest integer:
imageprocent := imageheight * Round(form2.Image1.Picture.height / 100) ;
And if you want more precision, it is better to include the multiply inside the Round parenthesis:
imageprocent := Round(imageheight * form2.Image1.Picture.height / 100) ;
form2.image1.picture.height := imageprocent * 100 / Round(form2.Image1.Picture.Height);
form2.image1.picture.width := imageprocent * 100 / Round(form2.Image1.Width);
Use Round for the whole expression in both instructions:
form2.image1.picture.height := Round(imageprocent * 100 /form2.Image1.Picture.Height);
form2.image1.picture.width := Round(imageprocent * 100 / form2.Image1.Width);
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.