0% found this document useful (0 votes)
43 views

Color Mixer Part 3

This document discusses getting the RGBA values of a specific pixel from an image in a PictureBox in a Visual Basic 2010 Windows Forms application. It includes code to open an image file with an OpenFileDialog, display the image in a PictureBox, and get the RGBA values at the coordinates specified in two TextBoxes when a button is clicked. The code handles exceptions if invalid coordinates are entered. Additional notes discuss adding a second form and hiding and showing forms. References for more information are also provided at the end.

Uploaded by

Mohamad Saad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Color Mixer Part 3

This document discusses getting the RGBA values of a specific pixel from an image in a PictureBox in a Visual Basic 2010 Windows Forms application. It includes code to open an image file with an OpenFileDialog, display the image in a PictureBox, and get the RGBA values at the coordinates specified in two TextBoxes when a button is clicked. The code handles exceptions if invalid coordinates are entered. Additional notes discuss adding a second form and hiding and showing forms. References for more information are also provided at the end.

Uploaded by

Mohamad Saad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Electro-Team

Interesting Education Visual Basic 2010

Get ARGB Of Specific Pixel

[email protected]

Open New Project

Windows Form Application

Add 1 Picbox And 3 Buttons

Add Openfiledialog1

Private Sub Button1_Click


OpenFileDialog1.Filter = "All Files|*.*|Image
Files|*.jpg;*.gif;*.png;*.bmp"
'Set the current file name filter string"this code will open all files"

OpenFileDialog1.ShowDialog()
'Display the dialog box to the user, call the ShowDialog() method.

PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
'dynamically load the images use Image class with FromFile() method.

End Sub

Run Time

Project\new Item

Add New Form

Note
Now you should back to From1 using solution

explorer and add code to button2 which have the


name (Form2) and add this code: Private Sub Button3_Click Me.Hide() Form2.Show

End Sub

Add 1 Picbox, 2 Labels, 2 Textboxs & 3 Buttons

Change Text Property

Private Sub Button1_Click


Dim openFile As New OpenFileDialog openFile.Filter = "Pictures Files| *.bmp;*.jpg;*.gif;*.wmf;*.tif;*.png" If openFile.ShowDialog() = DialogResult.OK Then PictureBox1.Image = Image.FromFile(openFile.FileName) Else

MessageBox.Show("Operation Canceled")
End If

End Sub

Private Sub Button2_Click

Try
Dim r_color As Color Dim picture_b As New Bitmap(PictureBox1.Image) r_color = picture_b.GetPixel(TextBox1.Text, TextBox2.Text) MsgBox("Alpha Value" & r_color.A & "Red Value: " & r_color.R & " Green Value: " & r_color.G & " Blue Value " & r_color.B) Catch ex As Exception

MsgBox(ex.Message)
End Try End Sub

Private Sub Button3_Click End End Sub

Run Time

This Pages Really Inspired Me


http://www.vbdotnetheaven.com/uploadfile/rohat ash/openfiledialog-control-in-vb-net-2010/ http://www.v-basic.net/2010/09/picture-get-pixel-

with-vbnet-2010.html

End Of Part Three


Produced by

Electro-Team
[email protected]

You might also like