Dim srcInfo As BITMAP GetObjectAPI picBuffer, Len(srcInfo), srcInfo Dim picBytes As Long picBytes = srcInfo.bmWidthBytes * srcInfo.bmHeight ReDim picOrig(1 To picBytes) As Byte ReDim picTemp(1 To picBytes) As ByteCall GetBitmapBits(picBuffer, picBytes, picOrig(1)) '//主测试区 Dim startTime As Long, b As IntegerstartTime = GetTickCount 'lastTime = startTime '//Main Loop Do While (GetTickCount - startTime) < 4000 b = (b + 30) Mod 200 'Label1.Caption = srcInfo.bmWidthBytes Call setBnC(b - 150, 1, picBytes) DoEvents BitBltTime = BitBltTime + 20 'PicTag.Refresh Loop PBM.Value = 26Dim DB As Single DB = 0.05 Do While (GetTickCount - startTime) < 8000 If DB < 1 Then DB = DB + 0.05 Else DB = DB + 0.3 'Label1.Caption = srcInfo.bmWidthBytes Call setBnC(0, DB, picBytes) DoEvents BitBltTime = BitBltTime + 0.5 'PicTag.Refresh Loop PBM.Value = 30 'MsgBox BitBltTime End SubPrivate Sub setBnC(Brightness As Integer, DuiBi As Single, picBytes As Long) Dim picY As Long, tempColor As Integer For picY = 1 To picBytes tempColor = (picOrig(picY) - 128) * DuiBi + 128 tempColor = tempColor + Brightness '溢出处理 If tempColor < 0 Then tempColor = 0 ElseIf tempColor > 255 Then tempColor = 255 End If picTemp(picY) = tempColor Next picY Call SetBitmapBits(picBuffer, picBytes, picTemp(1)) Call BitBlt(hDCdest, 0, 0, 800, 480, hDCbuffer, 0, 0, SRCCOPY) End SubpicBuffer是一个pictureBox的hDC,这是我的独创技术哦
你有算法吗?是不是AND和XOR
乘4之后:
0 8 32 0 4
对比度增加。
0 2 8 0 1
加4之后:
4 6 12 4 5
亮度增加。还有一种是曲线乘
0 2 8 0 10*X0 2*X2 8*X8 0*X0 1*X1对应256种亮度,乘数有256个曲线分量。先以固定乘数乘256个分量,再乘对应分量的亮度。这样则实现类似“伽玛”的亮度调整。
GetObjectAPI picBuffer, Len(srcInfo), srcInfo
Dim picBytes As Long
picBytes = srcInfo.bmWidthBytes * srcInfo.bmHeight
ReDim picOrig(1 To picBytes) As Byte
ReDim picTemp(1 To picBytes) As ByteCall GetBitmapBits(picBuffer, picBytes, picOrig(1))
'//主测试区
Dim startTime As Long, b As IntegerstartTime = GetTickCount
'lastTime = startTime
'//Main Loop
Do While (GetTickCount - startTime) < 4000
b = (b + 30) Mod 200
'Label1.Caption = srcInfo.bmWidthBytes
Call setBnC(b - 150, 1, picBytes)
DoEvents
BitBltTime = BitBltTime + 20
'PicTag.Refresh
Loop
PBM.Value = 26Dim DB As Single
DB = 0.05
Do While (GetTickCount - startTime) < 8000
If DB < 1 Then DB = DB + 0.05 Else DB = DB + 0.3
'Label1.Caption = srcInfo.bmWidthBytes
Call setBnC(0, DB, picBytes)
DoEvents
BitBltTime = BitBltTime + 0.5
'PicTag.Refresh
Loop
PBM.Value = 30
'MsgBox BitBltTime
End SubPrivate Sub setBnC(Brightness As Integer, DuiBi As Single, picBytes As Long)
Dim picY As Long, tempColor As Integer
For picY = 1 To picBytes
tempColor = (picOrig(picY) - 128) * DuiBi + 128
tempColor = tempColor + Brightness
'溢出处理
If tempColor < 0 Then
tempColor = 0
ElseIf tempColor > 255 Then
tempColor = 255
End If
picTemp(picY) = tempColor
Next picY
Call SetBitmapBits(picBuffer, picBytes, picTemp(1))
Call BitBlt(hDCdest, 0, 0, 800, 480, hDCbuffer, 0, 0, SRCCOPY)
End SubpicBuffer是一个pictureBox的hDC,这是我的独创技术哦