//読み込んだ画像サイズに応じてサムネイルボックスのサイズ変更
//画像サイズに応じて表示範囲の赤ボックスのサイズ変更


C_PICTURE:C286($picture)
C_PICTURE:C286($thumbnail)

$thumwidth:=80
$thumheight:=80
$picturesize:=600

$folder:=Folder:C1567(fk resources folder:K87:11)
$files:=$folder.files(fk ignore invisible:K87:22)
$filenum:=Random:C100%($files.length)

$path:=$files[$filenum].platformPath

READ PICTURE FILE:C678($path; $picture)  //ピクチャーをピクチャー変数へと代入
PICTURE PROPERTIES:C457($picture; $width; $height)

If ($width>$height)
	OBJECT GET COORDINATES:C663(*; "thumbnail1"; $l; $t; $r; $b)
	OBJECT SET COORDINATES:C1248(*; "thumbnail1"; $l; $t; ($thumwidth*($width/$height))+$l; $t+$thumheight)
	CREATE THUMBNAIL:C679($picture; $thumbnail; $thumwidth*($width/$height); $thumheight)
Else 
	OBJECT GET COORDINATES:C663(*; "thumbnail1"; $l; $t; $r; $b)
	OBJECT SET COORDINATES:C1248(*; "thumbnail1"; $l; $t; $l+$thumwidth; ($thumheight*($height/$width))+$t)
	CREATE THUMBNAIL:C679($picture; $thumbnail; $thumwidth; $thumheight*($height/$width))
End if 


Form:C1466.picture1:=$picture
Form:C1466.thumbnail1:=$thumbnail
OBJECT SET SCROLL POSITION:C906(*; "Input"; 0; 0)

OBJECT SET VISIBLE:C603(*; "Rectangle"; True:C214)

If ($width<$picturesize) | ($height<$picturesize)
	OBJECT SET COORDINATES:C1248(*; "Rectangle"; 714; 58; 714+$thumwidth; 58+$thumheight)
Else 
	$rate1:=$picturesize/$height
	$rate2:=$picturesize/$width
	OBJECT GET COORDINATES:C663(*; "thumbnail1"; $l; $t; $r; $b)
	OBJECT SET COORDINATES:C1248(*; "Rectangle"; 714; 58; 714+(($r-$l)*$rate2); 58+(($b-$t)*$rate1))
End if 

//If ($width<600)
//$widthrate:=1
//Else 
//$widthrate:=600/$width
//End if 

//If ($height<600)
//$heightrate:=1
//Else 
//$heightrate:=600/$height
//End if 

//OBJECT GET COORDINATES(*; "Rectangle"; $l; $t; $r; $b)
//OBJECT SET COORDINATES(*; "Rectangle"; $l; $t; $l+($thumwidth*$widthrate); $t+($thumheight*$heightrate))
