色の分析をActive Basicでおこなっています。
IFで条件に当てはまった場合gotoで途中の計算を飛ばしたいのですが、
ジャンプ先が不正となってしまいます。
ご指摘よろしくお願いいたします。
プログラムです
↓↓↓↓
#include "t.idx"
#include "s.sbp"
#N88BASIC
' ↓ ここからプログラムが実行されます
Dim a As String, FileName As String
Dim hBmp As Long
Dim nRed as Long, nGreen as Long, nBlue as Long,
Dim R as Single, G as Single, B as Single
Dim max as Single, min as Single
Dim H as Single, S as Single, V as Single
Dim Ha as Long, Sa as Single, Va as Single
Dim Hb as Long, Sb as Single, Vb as Single
Dim Hc as Long, Sc as Single, Vc as Single
Dim Hd as Long, Sd as Single, Vd as Single
Dim He as Long, Se as Single, Ve as Single
Dim Hf as Long, Sf as Single, Vf as Single
Dim nflame As Long
Dim x As Long, y As Long, r As Long
Dim hh as string
for nflame=1 to 2 ' ←この数字を、分析する画像ファイル数に変える
FileName="c:\ab\"+Str$(nflame)+".bmp" 'c:\ab\ というフォルダに、分析する画像を、1.bmp、2.bmp・・と保存しておく
BLoad(FileName , hBmp )
PutBmp( 1,1, hBmp )
GetBmp( 1,1,382 ,215, hBmp ) 'ここにx、y解像度をいれる
a="c:\ab\"+"ironobori1.txt" '色のデータ
open a as #1
cls '1列か1枚ごとに数値を0に戻す
Ha=0:Hb=0:Hc=0:Hd=0:He=0:Hf=0:Sa=0:Sb=0:Sc=0:Sd=0:Se=0:Sf=0:Va=0:Vb=0:Vc=0:Vd=0:Ve=0:Vf=0
for x=1 to 382 'この320が、画像解像度のx成分
for y=1 to 215 'この240が、画像解像度のy成分
r = Point( x, y )
nRed = ( r And &HFF )
nGreen = ( r And &HFF00 ) / &H100
nBlue = ( r And &HFF0000 ) / &H10000
R=nRed/255
G=nGreen/255
B=nBlue/255
If R=0 and G=0 and B=0 then goto 104
If R=90 and G=100 and B=100 then goto 104
**********************************
ここでgotoできません。
**********************************
If R => G and R=> B then max=R
If G => R and G => B then max=G
If B => R and B =>G then max=B
If R <= G and R <= B then min=R
If G <= R and G <= B then min=G
If B <= R and B <= G then min=B
If max=R then H=60*(G-B)/(max-min)
If max=G then H=60*(B-R)/(max-min)+120
If max=B then H=60*(R-G)/(max-min)+240
S=(max-min)/max
V=max
If H=>0 and H<60 then
Ha=Ha+1
Va=Va+V
Sa=Sa+S
End If
If H=>60 and H<120 then
Hb=Hb+1
Vb=Vb+V
Sb=Sb+S
End If
If H=>120 and H<180 then
Hc=Hc+1
Vc=Vc+V
Sc=Sc+S
End If
If H=>180 and H<240 then
Hd=Hd+1
Vd=Vd+V
Sd=Sd+S
End If
If H=>240 and H<300 then
He=He+1
Ve=Ve+V
Se=Se+S
End If
If H=>300 and H<=360 then
Hf=Hf+1
Vf=Vf+V
Sf=Sf+S
End If
Ha=Ha+0
Hb=Hb+0
Hc=Hc+0
Hd=Hd+0
He=He+0
Hf=Hf+0
Sa=Sa+0
Sb=Sb+0
Sc=Sc+0
Sd=Sd+0
Se=Se+0
Sf=Sf+0
Va=Va+0
Vb=Vb+0
Vc=Vc+0
Vd=Vd+0
Ve=Ve+0
Vf=Vf+0
Next y
Next x
print x,y,Ha,Hb,Hc,Hd,He,Hf
write #1,Ha,Hb,Hc,Hd,He,Hf
FinishBmp( hBmp )
Next nflame
close #1
End
Active Basicでゲームを作っています。
BGMを流すときに、PlaySound関数で音を鳴らそうと思ったのですが、
これはwav形式しか鳴らせないと知り、mciSendCommand関数を勉強することにしました。
mciSendCommand関数で、BGM(今回はmid)を読み出そうと思ったのですが、
『リピート再生』が出来ません。
いろいろ探してみたのですが、理解できませんでした。
そこで、いろいろ実験したのですが、どうも思うように動いてくれません。
MainWndとMenuの二つのウインドウがあります。
グローバル変数に
Dim bErr As Long
Dim mop As MCI_OPEN_PARMS
を定義してあります。
↓書いたコード(Menuウインドウ)
mop.lpstrElementName=".\BGM\bgm01.mid"
bErr=mciSendCommand(0,MCI_OPEN,MCI_OPEN_ELEMENT,mop)
If bErr Then
MessageBox(hMainWnd,"BGMの読み込みに失敗しましたので、強制終了します。","Error",MB_OK or MB_ICONHAND)
SendMessage(hMainWnd,WM_CLOSE,0,0)
End If
'再生
Dim mpp As MCI_PLAY_PARMS
mpp.dwCallback=hMainWnd
bErr=mciSendCommand(mop.wDeviceID,MCI_PLAY,MCI_NOTIFY,mpp)
If bErr Then
MessageBox(hMainWnd,"BGMの再生に失敗したので、強制終了します。","ERROR",MB_OK or MB_ICONHAND)
SendMessage(hMainWnd,WM_CLOSE,0,0)
End If
SetWindowPos(hMainWnd,HWND_TOP,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE or SWP_SHOWWINDOW)
SetTimer(hMainWnd,2,213000,0)
ここで、1回目の再生処理を入れて、SetTimer関数で、曲の長さ分のタイマーをセットして、曲が終了したらもう一度再生しなおすという方法でしました。
(探したサイトには、『リピート機能は無い』と書いてあったので)
↓タイムアウト時の処理(MainWnd)
If TimerID=2 Then
Dim mpp As MCI_PLAY_PARMS
mpp.dwCallback=hMainWnd
mpp.dwFrom=0
bErr=mciSendCommand(mop.wDeviceID,MCI_PLAY,MCI_NOTIFY,mpp)
If bErr Then
MessageBox(hMainWnd,"BGMの再生に失敗したので、強制終了します。","ERROR",MB_OK or MB_ICONHAND)
SendMessage(hMainWnd,WM_CLOSE,0,0)
End If
End If
初めて扱う部分なので、まだ良く分かっていません。
どなたか良いやり方をご存知の方がいらっしゃいましたらご教授下さい。
お願いします。