Silahkan Pilih Warna Yang Anda Sukai Untuk Kenyamanan Mata Anda

Ganti Warna Teks Yg Sesuai

Kamis, 12 April 2012

Source Code Brightnes gambar

Setiap orang yang punya hobby kutak-katik program (VB60), tiap kali dia menggunakan software, di dalam hatinya eh.. didalam otaknya, akan muncul berbagai pertanyaan. kok bisa begitu yaa.. seperti apa sih perintahnya?

Sebagai contoh pada software graphic, pada tool Brightnes atau contras, pertanyaan yang timbul, kok gambar bisa di bikin terang dan dibikin gelap. bagaaimana caranya.? Nah ini dia source code nya.

'Pada general


Const intUpperBoundX = 200 ' Deklarasi titik Horizontal
Const intUpperBoundY = 200 ' Deklarasi titik Ferical
Dim Pixels(1 To intUpperBoundX, 1 To intUpperBoundY) As Long
Private Sub Command1_Click()
Dim x, y, intAddOn As Integer
Dim bytRed, bytGreen, bytBlue, bytAverage As Integer
intAddOn = Val(Text1.Text)
For x = 1 To intUpperBoundX
For y = 1 To intUpperBoundY
Pixels(x, y) = Picture1.Point(x, y)
Next y
Next x
For x = 1 To intUpperBoundX
For y = 1 To intUpperBoundY
bytRed = Pixels(x, y) And &HFF
bytGreen = ((Pixels(x, y) And &HFF00) / &H100) Mod &H100
bytBlue = ((Pixels(x, y) And &HFF0000) / &H10000) Mod &H100
bytRed = bytRed + intAddOn
If bytRed > 255 Then bytRed = 255
bytGreen = bytGreen + intAddOn
If bytGreen > 255 Then bytGreen = 255
bytBlue = bytBlue + intAddOn
If bytBlue > 255 Then bytBlue = 255
Pixels(x, y) = RGB(bytRed, bytGreen, bytBlue)
Next y
Next x
For x = 1 To intUpperBoundX
For y = 1 To intUpperBoundY
Picture2.PSet (x, y), Pixels(x, y)
Next y
Next x
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Command1.Enabled = True
End Sub
Private Sub Form_Load()
Picture1.AutoSize = True
Picture2.AutoSize = True
Command1.Caption = "Tes"
Text1.Text = ""
End Sub

Private Sub VScroll1_Change()
Text1.Text = VScroll1.Value
Call Command1_Click
End Sub

Private Sub VScroll1_Scroll()
Text1.Text = VScroll1.Value
Call Command1_Click
End Sub


Cara Penerapannya, Buka VB60, buat projec baru. Pada form1, letakkan dua buah Picture Box, 1 Command Button, 1 Textbox dan satu vertical scroll. kemudian paste kan kode di atas. yang perlu diperhatikan adalah 'Scale Mode' property dari picture box, harus dalam scala Pixel.Untuk mudahnya, silahkan download contoh aplikasi jadinya disini :
Code Brightnes gbr

Tidak ada komentar:

Posting Komentar

Komentar anda tidak langsung dapat muncul, menunggu moderasi