1.VB 在桌面屏幕上画一条直线如何让它重绘?
VB 在桌面屏幕上画一条直线如何让它重绘?
'屏幕重绘 源码如下
'画多线声波色条
Public Sub DrawFrequencies(intSamples() As Integer,源码源码 笔记 picbox As PictureBox)
'FFT_SAMPLES =
Dim sngRealOut(FFT_SAMPLES - 1) As Single
Dim sngBand As Single
Dim hBrush As Long
Dim i As Long
Dim j As Long
Dim intRed As Integer
Dim intGreen As Integer
Dim intBlue As Integer
Dim rcBand As RECT
If UBound(intSamples) < FFT_SAMPLES - 1 Then Exit Sub
If clsFFT Is Nothing Then
Set clsFFT = New clsFourier
clsFFT.NumberOfSamples = FFT_SAMPLES
clsFFT.WithTimeWindow = 1
End If
'读入数据
For i = 0 To FFT_SAMPLES - 1 'FFT_SAMPLES =
clsFFT.RealIn(i + 1) = intSamples(i) '动态数值传送
Next
' lower band amplitudes
For i = 0 To FFT_BANDS - 1 'band(i) = 0 FFT_BANDS =
band(i) = band(i) - FFT_BANDLOWER 'FFT_BANDLOWER = 0.
If band(i) < 0 Then band(i) = 0
Next
'band(0) = 0 : band(1) = 0 : band(2) = 0 : band(3) = 0 : band(4) = 0 : band(5) = 0 : band(6) = 0
For i = 0 To FFT_SAMPLES / 2
'FFT_SAMPLES =
sngRealOut(i) = clsFFT.ComplexOut(i + 1) / (FFT_SAMPLES / 4) /
If sngRealOut(i) > FFT_MAXAMPLITUDE Then
sngRealOut(i) = FFT_MAXAMPLITUDE
End If
sngRealOut(i) = sngRealOut(i) / FFT_MAXAMPLITUDE 'FFT_MAXAMPLITUDE = 0.2
Next
j = FFT_STARTINDEX
For i = 0 To FFT_BANDS - 1 'FFT_BANDS =
For j = j To j + FFT_BANDWIDTH 'FFT_BANDWIDTH = 3
sngBand = sngBand + sngRealOut(j)
Next
sngBand = (sngBand * (Hanning(i + 3, FFT_BANDS + 3) + 1)) / FFT_BANDWIDTH
'MsgBox band(i) '--------------------------------
If band(i) < sngBand Then band(i) = sngBand
If band(i) > 1 Then band(i) = 1
j = j + FFT_BANDSPACE
Next
' draw bars
picbox.Cls
intRed =
intBlue =
'画整个色块 共块色条
For i = 0 To FFT_BANDS - 1 'FFT_BANDS = picbox.ScaleHeight =
intGreen = (band(i) * ) ' i ( 0-)
hBrush = CreateSolidBrush(RGB(intRed, intGreen, intBlue))
'画单个色块
With rcBand
.Right = i * (DRW_BARWIDTH + DRW_BARSPACE) + DRW_BARWIDTH + DRW_BARXOFF
.Left = i * (DRW_BARWIDTH + DRW_BARSPACE) + DRW_BARXOFF
'单个色块的高度 忽上忽下 DRW_BARYOFF=2 常数 band(i)自定精度数组(0-) 从小到大
'.Top = max(DRW_BARYOFF, Min(picbox.ScaleHeight, picbox.ScaleHeight - (picbox.ScaleHeight * band(i))) - DRW_BARYOFF) ' - 1)
.Top = max(2, Min(, - ( * band(i))) - 2)
.Bottom = picbox.ScaleHeight - DRW_BARYOFF
End With
FillRect picbox.hdc, rcBand, hBrush '用指定刷子填充色块区域
DeleteObject hBrush
Next
End Sub