Lab

Flash :: Bitmap Resize

threeword 2009. 4. 17. 17:42
비율로 맞추기 (가로,세로 모두 영역안에)

.Variable
e.currentTarget - 로더
bmp - 비트맵
container - 로드이미지 넣을 컨테이너

.Code
if (e.currentTarget.width >= e.currentTarget.height) {
bmp.width = container.width;
bmp.height = container.width * ( e.currentTarget.height / e.currentTarget.width);
}else {
bmp.height = container.height;
bmp.width =  container.height * (e.currentTarget.width / e.currentTarget.height);
}

--------------------------------------------------------------------------------------

비율로 맞추기 (가로,세로 한쪽만 영역안에)

.Variable
e.currentTarget - 로더
bmp - 비트맵
container - 로드이미지 넣을 컨테이너

.Code
if (e.currentTarget.width >= e.currentTarget.height) {
bmp.height = container.height;
bmp.width =  container.height * (e.currentTarget.width / e.currentTarget.height);

}else {
bmp.width = container.width;
bmp.height = container.width * ( e.currentTarget.height / e.currentTarget.width);
}