目次

90°回転

 90°回転は、元画像からピクセルデータを取得しておき
 横と縦の座標を入れ替えて、右回転と左回転の情報を付加
 します。

 元画像を、長方形の板に貼り付けて、右あるいは左に
 90°回転後、展開して平面に戻す操作と同じです。

 左端に元画像をおいて、この画像を左右に90°回転させて
 表示させると、次のようになります。
 (縦に、白線を入れて分かりやすくしています。)




処理内容

 左右の90°回転は、X、Y座標を入れ替えて、オフセットを  操作して実現します。  左90°回転   元画像のX、Y座標が、変数i、jに含まれているとすると   次の代入と計算で、回転画像の座標を求められます。    x = j    y = xlast -1 - i  右90°回転   元画像のX、Y座標が、変数i、jに含まれているとすると   次の代入と計算で、回転画像の座標を求められます。    x = ylast - j    y = i  まとめると、以下のコードとなります。 --------------------------------------------------  title "rotate with 90 degree" ; set screen dimensions  screen 0,80+2*(60+1),80 ; constants  ylast = 60  xlast = 80 ; get image  picload "rline.bmp",1 ;  gosub *rotate_image  gosub *rotate_image2  stop *rotate_image  for j,0,ylast,1   for i,0,xlast,1    ; get informations of current position    pget i,j    ; counter clockwise rotation    x = j    y = xlast -1 - i    ; show    pset x+xlast+1,y   next  next  return *rotate_image2  for j,0,ylast,1   for i,0,xlast,1    ; get informations of current position    pget i,j    ; clockwise rotation    x = ylast - j    y = i    ; show    pset x+xlast+ylast+1,y   next  next  return  end --------------------------------------------------

目次

inserted by FC2 system