增加 Picture亮度是:
Dim Bright As Integer '亮度
Bright = 20 '設亮度增20%(若用負數則亮度變暗如-20)
Picture1.AutoRedraw = True
For Y = 1 To Picture1.ScaleHeight Step 15
For X = 1 To Picture1.ScaleWidth Step 15
Tmp& = Picture1.Point(X, Y)
If Len(Hex(Tmp&)) < 8 Then RS = Right(Hex(Tmp&), 2)
If Len(Hex(Tmp&)) = 6 Then
BS = Left(Hex(Tmp&), 2)
GS = Mid(Hex(Tmp&), 3, 2)
End If
If Len(Hex(Tmp&)) = 4 Then
GS = Left(Hex(Tmp&), 2)
End If
If Len(Hex(Tmp&)) > 1 Then R = Val("&H" + RS) Else R = 0
If Len(Hex(Tmp&)) > 3 Then G = Val("&H" + GS) Else G = 0
If Len(Hex(Tmp&)) > 5 Then B = Val("&H" + BS) Else B = 0
If Len(Hex(Tmp&)) = 8 Then R = 1: G = 1: B = 1
PerC = (100 + Bright) / 100
R = Fix(R * PerC): G = Fix(G * PerC): B = Fix(B * PerC)
If R > 255 Then R = 255
If G > 255 Then G = 255
If B > 255 Then B = 255
If R = 0 Then R = Bright
If G = 0 Then G = Bright
If B = 0 Then B = Bright
Picture1.PSet (X, Y), RGB(R, G, B)
Next
Next
Picture1.AutoRedraw = False
那如何變暗ㄚ?
2006-11-18 12:50:57 · 2 個解答 · 發問者 鳴 5 in 電腦與網際網路 ➔ 程式設計
我不要若用負數則亮度變暗如-20
可否提供別的寫法謝謝喔
2006-11-18 12:56:49 · update #1
介不介意使用API去做?
2006-11-20 00:23:48 補充:
'表單置1個HScrollBar及2個PictureBoxConst HALFTONE = 4Private Type CJ caSize As Integer caFlags As Integer caIlluminantIndex As Integer caRedGamma As Integer caGreenGamma As Integer caBlueGamma As Integer caReferenceBlack As Integer caReferenceWhite As Integer caContrast As Integer caBrightness As Integer caColorfulness As Integer caRedGreenTint As IntegerEnd TypePrivate Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As LongPrivate Declare Function SetStretchBltMode Lib "gdi32" (ByVal hdc As Long, ByVal nStretchMode As Long) As LongPrivate Declare Function GetColorAdjustment Lib "gdi32" (ByVal hdc As Long, lpca As CJ) As LongPrivate Declare Function SetColorAdjustment Lib "gdi32" (ByVal hdc As Long, lpca As CJ) As LongPrivate Declare Function GetStretchBltMode Lib "gdi32" (ByVal hdc As Long) As LongDim C As CJPrivate Sub Form_Load() Show With HScroll1 .Max = 100 .Min = -100 .Value = 0 End With '載入圖片 Set Picture1.Picture = "C:\Test.bmp" Picture1.ScaleMode = vbPixels GetColorAdjustment Picture2.hdc, C C.caSize = Len(C) nBHEnd SubPrivate Sub HScroll1_Change() nBHEnd SubPrivate Sub HScroll1_Scroll() nBHEnd SubSub nBH() DoEvents C.caBrightness = HScroll1 If GetStretchBltMode(Picture2.hdc) <> HALFTONE Then SetStretchBltMode Picture2.hdc, HALFTONE SetColorAdjustment Picture2.hdc, C StretchBlt Picture2.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, vbSrcCopyEnd Sub
2006-11-19 19:23:48 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋
api好ㄚ?謝謝!
2006-11-19 04:21:38 · answer #2 · answered by 鳴 5 · 0⤊ 0⤋