目次
前
次
間引き処理
間引きは、画像を横方向に1ピクセルずつ飛び越して表示するか
縦方向に1ライン飛び越して表示するかです。
基本は、画像サイズを1/2に縮小する処理があれば、それを
応用すれば、実現できます。
- 横方向は、1ピクセル飛びに表示
- 縦方向は、1ライン飛びに表示
横方向は、1ピクセル飛びに表示すると、次のようになります。
縦方向は、1ライン飛びに表示してみると、以下です。
横方向間引き
横方向は1ピクセル飛びに処理するので、for文のステップ数を2にします。
ソースコードは、次のように記述します。
---------------------------------------------------
title "Make 1/2 size"
; set screen dimensions
screen 0,640+320,480
; constants
ylast = 480
xlast = 640
; get image
picload "NEC_0105.JPG",1
gosub *skip_pixel
stop
;+++++++++++++++++++++++++++++++++++++++++++++
*skip_pixel
for j,0,ylast,1
for i,0,xlast,2
; get informations of current position
pget i,j
; show
pset i/2+xlast,j
next
next
return
;+++++++++++++++++++++++++++++++++++++++++++++
end
---------------------------------------------------
縦方向間引き
縦方向は1ライン飛びに処理するので、for文のステップ数を2にします。
ソースコードは、次のように記述します。
---------------------------------------------------
title "Make 1/2line"
; set screen dimensions
screen 0,640,480
; constants
ylast = 480
xlast = 640
; get image
picload "NEC_0105.JPG",1
gosub *skip_line
stop
;+++++++++++++++++++++++++++++++++++++++++++++
*skip_line
for j,0,ylast,2
for i,0,xlast,1
; get informations of current position
pget i,j
; show
pset i,j/2
next
next
return
;+++++++++++++++++++++++++++++++++++++++++++++
end
---------------------------------------------------
目次
前
次